Using Snapshot Monitor SQL Administrative Views for Performance

Download Report

Transcript Using Snapshot Monitor SQL Administrative Views for Performance

Anthony Reina - Accelerated Value Specialist
[email protected]
Using Snapshot monitor SQL
Administrative Views for Performance
Analysis on V10.1
Information Management
© 2010 IBM Corporation
Information Management
IBM Software
Accelerated Value Program
•The IBM Software Accelerated Value Program
delivers a proactive, cost-reducing, and
productivity enhancing advisory service. The
program pairs you with an assigned team who
build a foundational understanding of your
overall environment. Through that understanding,
the trusted partner works to facilitate faster
deployment, lifecycle leadership, risk
mitigation, and more by identifying ways to
improve your environment, staff skill set, and
processes.
http://www-01.ibm.com/software/support/acceleratedvalue/
2
© 2010 IBM Corporation
Information Management
AGENDA
 Introduction
 Snapshot Administrative Views
 Usage/Example
3
© 2010 IBM Corporation
Information Management
Introduction
Often times we encounter situations where increase
in the workload against the database starts hindering
overall database performance. Although this can be
caused by the environment configurations, changes to
the system, resource bottleneck, or simply increase
in workload. It’s very possible queries running on
the database are not running optimal as expected.
Different methods for identifying long running sql’s…





4
DB2 Snapshots (ie. Application, Dynamic, etc…)
DB2 Diagnostics (ie. db2pd, db2fodc –perf/hang)
3rd Party Monitoring Tools
DB2 Access Plans
Snapshot Administrative Views
© 2010 IBM Corporation
Information Management
Snapshot Administrative Views
• System Defined
• Provide a primary, easy to use programmatic interface.
• Includes a collection of…
 Built-in views
 Table functions
 Procedures
 Scalar functions for various DB2 task
• Can be invoked from…
 SQL Based application
 DB2 Command Line
 Command Script
• DFT_MONT_STMT and DFT_MON_TIMESTAMP dbm cfg should be
enabled.
5
© 2010 IBM Corporation
Information Management
Snapshot Administrative Views
• APPL_PERFORMANCE displays information about the
percentage of rows selected by an application.
• LONG_RUNNING_SQL returns SQL statements executed in
the currently connected database. This can be used
to verify long-running SQL statements in the
database.
• QUERY_PREP_COST returns a list of statements with
information about the time required to prepare the
statement.
• TOP_DYNAMIC_SQL returns the top dynamic SQL
statements sortable by number of executions,
average execution time, number of sorts, or sorts
per statement.
6
© 2010 IBM Corporation
Information Management
Snapshot Administrative Views
APPL_PERFORMANCE
Column Name
7
Data Type
Description
SNAPSHOT_TIMESTAMP
TIMESTAMP
The date and time the snapshot was
taken.
AUTHID
VARCHAR (128)
Authorization ID
APPL_NAME
VARCHAR (256)
Application Name
AGENT_ID
BIGINT
Agent ID / Application Handle
PERCENT_ROWS_SELECTED
DECIMAL (5,2)
The percent of rows read from disk that
were actually returned to the application.
DBPARTITIONNUM
SMALLINT
The database partition from which the
data was retrieved for this row.
MEMBER
SMALLINT
Numeric identifier for the database
member from which the data was
retrieved.
© 2010 IBM Corporation
Information Management
Snapshot Administrative Views
LONG_RUNNING_SQL
Column Name
8
Data Type
Description
SNAPSHOT_TIMESTAMP
TIMESTAMP
The date and time the snapshot was
taken.
ELAPSED_TIME_MIN
INTEGER
Elapsed time of the statement in minutes.
AGENT_ID
BIGINT
Agent ID / Application Handle
APPL_NAME
VARCHAR (256)
Application Name
APPL_STATUS
VARCHAR (22)
Application Status (ie. CONNECTED,
UOWEXEC, UOWWAIT, BACKUP, etc.)
AUTHID
VARCHAR (128)
Authorization ID
INBOUND_COMM_ADDRESS
VARCHAR (32)
Inbound Communication Address
STMT_TEXT
CLOB (16 M)
Statement Text
DBPARTITIONNUM
SMALLINT
The database partition from which the
data was retrieved for this row.
MEMBER
SMALLINT
Numeric identifier for the database
member from which the data was
retrieved.
© 2010 IBM Corporation
Information Management
Snapshot Administrative Views
QUERY_PREP_COST
Column Name
9
Data Type
Description
SNAPSHOT_TIMESTAMP
TIMESTAMP
The date and time the snapshot was taken.
NUM_EXECUTIONS
BIGINT
The number of times that an SQL
statement has been executed.
AVERAGE_EXECUTION_TIME_S
BIGINT
Average execution time in seconds.
AVERAGE_EXECUTION_TIME_MS
BIGINT
Average execution time in – fractional, in
seconds
PREP_TIME_MS
BIGINT
The longest amount of time in
microseconds that was required to prepare
a specific SQL statement.
PREP_TIME_PERCENT
DECIMAL (5,2)
Percent of execution time spent on
preparation.
STMT_TEXT
CLOB (16 M)
Statement Text
DBPARTITIONNUM
SMALLINT
The database partition from which the data
was retrieved for this row.
MEMBER
SMALLINT
Numeric identifier for the database member
from which the data was retrieved.
© 2010 IBM Corporation
Information Management
Snapshot Administrative Views
TOP_DYNAMIC_SQL
Column Name
10
Data Type
Description
SNAPSHOT_TIMESTAMP
TIMESTAMP
The date and time the snapshot was
taken.
NUM_EXECUTIONS
BIGINT
The number of times that an SQL
statement has been executed.
AVERAGE_EXECUTION_TIME_S
BIGINT
Average execution time in seconds.
STMT_SORTS
BIGINT
The total number of times that a set of
data
SORTS_PER_EXECUTION
BIGINT
Number of sorts per statement execution.
STMT_TEXT
CLOB (2 M)
Statement Text
DBPARTITIONNUM
SMALLINT
The database partition from which the
data was retrieved for this row.
MEMBER
SMALLINT
Numeric identifier for the database
member from which the data was
retrieved.
© 2010 IBM Corporation
Information Management
Example
Scenario :
Two set of workload is run from the
environment identified as run_wkld1 and
run_wkld2.
DB2 DBA, would like to identify what are
the queries being run from the two
workload processand identify potential
SQL problems.
11
© 2010 IBM Corporation
Information Management
Example
Use APPL_PERFORMANCE to see what
applications are running…
12
© 2010 IBM Corporation
Information Management
Example
APPL_PERFORMANCE view output
The db2bp for
AGENT_ID 75, 8,
and 7 would more
likely to be
running SQL’s.
13
© 2010 IBM Corporation
Information Management
Example
Use LONG_RUNNING_SQL to identify longest
running queries that are currently being
executed…
14
© 2010 IBM Corporation
Information Management
Example
LONG_RUNNING_SQL view output
1st data collected
AGENT_ID 8 and 7 is running for 1 min.
and actual query is identified.
15
© 2010 IBM Corporation
Information Management
Example
LONG_RUNNING_SQL view output
2nd data collected
AGENT_ID 8 and 7 is running for 3 min.
and actual query is identified.
16
© 2010 IBM Corporation
Information Management
Example
Use QUERY_PREP_COST_TIME to determined how
frequent a query is run as well as average
execution time for each query…
17
© 2010 IBM Corporation
Information Management
Example
QUERY_PREP_COST view output
Q1
Q2/
AGENT_ID 8
Q3
Q4
Q5/
AGENT_ID 7
18
© 2010 IBM Corporation
Information Management
Example
Use TOP_DYNAMIC_SQL to determine most
frequently executed and longest-running SQL
statements…
19
© 2010 IBM Corporation
Information Management
Example
TOP_DYNAMIC_SQL view output
Q1
Q2/
AGENT_ID 8
Q3
Q4
Q5/
AGENT_ID 7
20
© 2010 IBM Corporation
Information Management
Other Snapshot Admin Views
• BP_HITRATIO returns bufferpool hit ratios,
including total, data , XDA, ratio, and index hit
ratio.
• CONTAINER_UTILIZATION returns information about the
table space containers and utilization rates.
• LOG_UTILIZATION returns information for the
currently connected database per partition.
• Full list of Snapshot Admin Views
21
© 2010 IBM Corporation
Information Management
Questions?
22
© 2010 IBM Corporation