The unit of work event monitor can collect a listing of packages used within a unit of work. This information can be used to determine which stored procedures within an application might be taking more time than expected to run.
Starting with DB2® Version 9.7 Fix Pack 1, you can have information about the packages used within units of work included in the data the event monitor collects. This information is written to the unformatted event table along with the rest of the information associated with the event when the unit of work ends.
As the list of information collected for the package listing suggests, information is captured not only for each package but also for each invocation of a routine within a package.
Elapsed time is also tracked. The time calculated for a given invocation starts from the first execution of a section within a package until the database manager switches to another package. See Examples to see more about how elapsed time is tracked.
When you enable the collection of package list information, the unit of work event monitor writes two records to the unformatted event (UE) table for each unit of work. The first record contains the basic unit of work event monitor data. The next record contains the package listing information.
-------------------------------------------------------
Event ID : 12
Event Type : UOW
Event Timestamp : 2009-12-08-14.44.39.162707
Member : 0
Release : 9070200
-------------------------------------------------------
Database Level Details
----------------------
Database Member Activation Time : 2009-12-08-14.41.55.089416
Coordinator Member : 0
Connection Level Details
------------------------
Application ID : *LOCAL.gstager.091208194155
Application Handle : 21
Application Name : db2bp
Session Authorization ID :
System Authorization ID :
Connection Timestamp : 2009-12-08-14.41.55.089416
Client Process ID : 13043
Client Platform : LINUXX8664
Client Product ID : SQL09072
Client Protocol : LOCAL
Client Hostname : HOSTX
Client Port Number : 0
UOW Level Details
------------------------
Start Time : 2009-12-08-14.44.39.160651
Stop Time : 2009-12-08-14.44.39.162707
Completion Status : COMMIT
UOW ID : 12
Workoad Occurrence ID : 1
Workload Name : SYSDEFAULTUSERWORKLOAD
Workoad ID : 1
Service Superclass Name : SYSDEFAULTUSERCLASS
Service Subclass Name : SYSDEFAULTSUBCLASS
Service Class ID : 13
Client Userid :
Client Workstation Name :
Client Application Name :
Client Accounting String :
Local Transaction ID : 000000000000013B
Global Transaction ID : 0000000000000000000000000000000000000000
Log Space Used : 124
UOW Metrics
------------------------
TOTAL_CPU_TIME : 1591
TOTAL_WAIT_TIME : 8363
ACT_ABORTED_TOTAL : 0
ACT_COMPLETED_TOTAL : 1
ACT_REJECTED_TOTAL: : 0
AGENT_WAIT_TIME : 87
AGENT_WAITS_TOTAL : 1
APP_RQSTS_COMPLETED_TOTAL : 1
.
.
.
Package List
------------------------
Package List Size : 2
Package List Exceeded : no
PACKAGE_ID NESTING_LEVEL ROUTINE_ID INVOCATION_ID PACKAGE_ELAPSED_TIME
-------------------- ------------- ----------- -------------------- --------------------
240 0 0 0 0
330 1 66539 1 1
The number of packages that appear in the package list for a given unit of work is reflected in the package_list_count monitor element ("Package List Size" in the preceding report), which is included with the base unit of work event monitor data. If the number of packages used with the unit of work exceeds the value specified in the mon_pkglist_sz configuration parameter, the additional packages are not included in the package listing. However, the package_list_exceeded monitor element indicates whether there were more packages than would fit into the package list. This monitor element is returned along with the base information for the unit of work event monitor ("Package List Exceeded" in Figure 1). If the value for this monitor element is YES, you can increase the value for mon_pkglist_sz to have a larger number of packages included in the package list.
PACKAGE_ID NESTING_LEVEL ROUTINE_ID INVOCATION_ID ELAPSED_TIME
---------- ------------- ---------- ------------- ------------
300 0 0 0 100
In this case, there is one entry on the package list, which reflects the execution of one or more sections in the package. All sections executed from the same package are considered to be part of the same package invocation.
PACKAGE_ID NESTING_LEVEL ROUTINE_ID INOVATION_ID ELAPSED_TIME
---------- ------------- ---------- ------------ ------------
300 0 0 0 21
300 1 806 1 100
This output shows two entries in the list. One entry is for the call to the stored procedure, and one for the execution of the three sections within the stored procedure. The NESTING_LEVEL for the second entry in the list reflects the fact that the stored procedure was called from another package.
Application
EXEC PACKAGEA
EXEC PACKAGEB
EXEC PACKAGEA
Assume also that each of these invocations
require 100 ms, 25 ms, and 460 ms, respectively. The following output
shows what the package listing would look like:PACKAGE_ID NESTING_LEVEL ROUTINE_ID INVOCATION_ID ELAPSED_TIME
---------- ------------- ---------- ------------- ------------
300 0 0 0 560
301 0 0 0 25
In this case, there are two entries in the list. Package A, with PACKAGE_ID 300 had sections that ran for 560 ms in total. Package B ran for 25 ms. Package A is represented by a single line because each invocation has the same INVOCATION_ID and NESTING_LEVEL. INVOCATION_ID and NESTING_LEVEL remain at 0, because no stored procedures were called in either package.
In this example, there are 3 packages with IDs 100, 101, and 102. The application is in package 100. There are two stored procedures with IDs 201 and 202. The first stored procedure (SP1) is in package 101, and the second (SP2) is in package 102. The pseudocode that follows is a representation of this unit of work:
Application
CALL SP1 a
INSERT INTO T1 VALUES(7) b
CALL SP2 c
INSERT INTO T2 VALUES(8)
CALL SP2 d
INSERT INTO T2 VALUES(8)
PACKAGE_ID NESTING_LEVEL ROUTINE_ID INVOCATION_ID ELAPSED_TIME
---------- ------------- ---------- ------------- ------------
100 0 0 0 21
101 1 1 201 1 40
102 2 2 202 1 3 35
102 2 202 2 3 35