View
215
Download
1
Category
Preview:
Citation preview
© 2010 IBM Corporation
Information Management
Using Snapshot monitor SQL Administrative Views for Performance Analysis on V10.1
Anthony Reina - Accelerated Value Specialist
aereina@ca.ibm.com
© 2010 IBM Corporation
Information Management
2
•The IBM Software Accelerated Value Programdelivers a proactive, cost-reducing, andproductivity enhancing advisory service. Theprogram pairs you with an assigned team whobuild a foundational understanding of youroverall environment. Through that understanding,the trusted partner works to facilitate fasterdeployment, lifecycle leadership, riskmitigation, and more by identifying ways toimprove your environment, staff skill set, andprocesses.
http://www-01.ibm.com/software/support/acceleratedvalue/
IBM Software Accelerated Value Program
© 2010 IBM Corporation
Information Management
3
AGENDA
Introduction Snapshot Administrative Views Usage/Example
© 2010 IBM Corporation
Information Management
4
IntroductionOften times we encounter situations where increasein the workload against the database starts hinderingoverall database performance. Although this can becaused by the environment configurations, changes tothe system, resource bottleneck, or simply increasein workload. It’s very possible queries running onthe database are not running optimal as expected. Different methods for identifying long running sql’s…
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
5
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.
© 2010 IBM Corporation
Information Management
6
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.
© 2010 IBM Corporation
Information Management
7
Snapshot Administrative ViewsAPPL_PERFORMANCE
Column Name Data Type DescriptionSNAPSHOT_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
8
Snapshot Administrative ViewsLONG_RUNNING_SQL
Column Name Data Type DescriptionSNAPSHOT_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
9
Snapshot Administrative ViewsQUERY_PREP_COST
Column Name 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
10
Snapshot Administrative ViewsTOP_DYNAMIC_SQL
Column Name Data Type DescriptionSNAPSHOT_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
11
Example
Scenario :
Two set of workload is run from the environment identified as run_wkld1 andrun_wkld2.
DB2 DBA, would like to identify what are
the queries being run from the twoworkload processand identify potentialSQL problems.
© 2010 IBM Corporation
Information Management
12
Example
Use APPL_PERFORMANCE to see what applications are running…
© 2010 IBM Corporation
Information Management
13
Example
APPL_PERFORMANCE view output
The db2bp for AGENT_ID 75, 8, and 7 would more likely to be running SQL’s.
© 2010 IBM Corporation
Information Management
14
Example
Use LONG_RUNNING_SQL to identify longest running queries that are currently being executed…
© 2010 IBM Corporation
Information Management
15
Example
LONG_RUNNING_SQL view output
1st data collected AGENT_ID 8 and 7 is running for 1 min. and actual query is identified.
© 2010 IBM Corporation
Information Management
16
Example
LONG_RUNNING_SQL view output
2nd data collected AGENT_ID 8 and 7 is running for 3 min. and actual query is identified.
© 2010 IBM Corporation
Information Management
17
Example
Use QUERY_PREP_COST_TIME to determined how frequent a query is run as well as average execution time for each query…
© 2010 IBM Corporation
Information Management
18
Example
QUERY_PREP_COST view output
Q1
Q2/AGENT_ID 8
Q3
Q4
Q5/AGENT_ID 7
© 2010 IBM Corporation
Information Management
19
Example
Use TOP_DYNAMIC_SQL to determine most frequently executed and longest-running SQL statements…
© 2010 IBM Corporation
Information Management
20
Example
TOP_DYNAMIC_SQL view output
Q1
Q2/AGENT_ID 8
Q3
Q4Q5/AGENT_ID 7
© 2010 IBM Corporation
Information Management
21
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
© 2010 IBM Corporation
Information Management
22
Questions?
Recommended