Seeing where time is spent across the system
You can use the time-spent monitor elements to get a view of where time is being spent in the system. Time spent monitor elements can be used to report on specific units of work, service subclasses, workloads or connections.
About this task
Notes:
- The values shown in the output for queries are for illustrative purposes only, and should not be construed as representative of what you might see in your own system.
- This task shows you how to retrieve specific time-spent monitor elements. You can also use new formatting functions introduced in version 9.7 Fix Pack 1 to retrieve time spent monitor elements that meet specific criteria, such as those with non-zero values, those within a certain range of values that you specify, or the top n monitor element (for example, the top five wait times). Example 4 illustrates how these functions work.
Procedure
Example
-
Example 1: Determining the average across all connections of
the time spent waiting relative to overall request time.
- This example is similar to the preceding one, except that the calculation of the average percentage wait time is done within the SQL:
WITH PCTWAIT AS ( SELECT SUM(TOTAL_WAIT_TIME)AS WAIT_TIME, SUM(TOTAL_RQST_TIME)AS RQST_TIME FROM TABLE(MON_GET_CONNECTION(NULL,NULL)) AS METRICS) SELECT WAIT_TIME, RQST_TIME, CASE WHEN RQST_TIME > 0 THEN DEC((FLOAT(WAIT_TIME))/FLOAT(RQST_TIME) * 100,5,2) ELSE NULL END AS WAIT_PCT FROM PCTWAIT
The results of running the preceding query would look something like this:WAIT_TIME RQST_TIME WAIT_PCT -------------------- -------------------- -------- 1515 2439 62.11 1 record(s) selected.
Example 2: Comparing total wait time against selected component
processing times for a specific service subclass
- This example shows how you can compare time spent in specific types of component processing with the time spent waiting:
SELECT SUM(TOTAL_WAIT_TIME) AS WAIT, SUM(TOTAL_COMPILE_PROC_TIME) AS COMPILE, SUM(TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS IMP_COMPILE, SUM(TOTAL_SECTION_PROC_TIME) AS SECTION, SUM(TOTAL_COMMIT_PROC_TIME) AS COMMIT, SUM(TOTAL_REORG_PROC_TIME) AS REORG, SUM(TOTAL_RUNSTATS_PROC_TIME) AS RUNSTATS, SUM(TOTAL_ROLLBACK_PROC_TIME) AS ROLLBACK, SUM(TOTAL_LOAD_PROC_TIME) AS LOAD FROM TABLE(MON_GET_SERVICE_SUBCLASS( 'SYSDEFAULTUSERCLASS','SYSDEFAULTSUBCLASS',NULL))
The results of the preceding query would look something like this (the output rows from the query have been split for presentation purposes):WAIT COMPILE IMP_COMPILE SECTION COMMIT -------------------- -------------------- -------------------- -------------------- -------------------- 611 1931 0 395 15 REORG RUNSTATS ROLLBACK LOAD -------------------- -------------------- -------------------- -------------------- 0 432 18 0 1 record(s) selected.
The numbers reported could be used to construct a pie chart to show the relative time spent waiting as compared to time spent in different stages of processing (component times of 0 are not included):
Example 3: View the ratio of total time spent as compared to
processing time in different components
This example shows you how you can get an overview of the time spent doing work in different stages of processing (components), relative to the total time spent in that component. The following query computes the ratio (expressed as a percentage) of the time spent in actual processing as compared to the total elapsed time spent in a specific component.
WITH PCTPROC AS ( SELECT SUM(TOTAL_SECTION_TIME) AS SECT_TIME, SUM(TOTAL_SECTION_PROC_TIME) AS SECT_PROC_TIME, SUM(TOTAL_COMPILE_TIME) AS COMP_TIME, SUM(TOTAL_COMPILE_PROC_TIME) AS COMP_PROC_TIME, SUM(TOTAL_IMPLICIT_COMPILE_TIME) AS IMP_C_TIME, SUM(TOTAL_IMPLICIT_COMPILE_PROC_TIME) AS IMP_C_PROC_TIME, SUM(TOTAL_COMMIT_TIME) AS COMMIT_TIME, SUM(TOTAL_COMMIT_PROC_TIME) AS COMMIT_PROC_TIME, SUM(TOTAL_ROLLBACK_TIME) AS ROLLBACK_TIME, SUM(TOTAL_ROLLBACK_PROC_TIME) AS ROLLBACK_PROC_TIME, SUM(TOTAL_RUNSTATS_TIME) AS RUNSTATS_TIME, SUM(TOTAL_RUNSTATS_PROC_TIME)AS RUNSTATS_PROC_TIME, SUM(TOTAL_REORG_TIME) AS REORG_TIME, SUM(TOTAL_REORG_PROC_TIME) AS REORG_PROC_TIME, SUM(TOTAL_LOAD_TIME) AS LOAD_TIME, SUM(TOTAL_LOAD_PROC_TIME) AS LOAD_PROC_TIME FROM TABLE(MON_GET_CONNECTION(NULL, -2)) AS METRICS) SELECT CASE WHEN SECT_TIME > 0 THEN DEC((FLOAT(SECT_PROC_TIME) / FLOAT(SECT_TIME)) * 100,5,1) ELSE NULL END AS SECT_PROC_PCT, CASE WHEN COMP_TIME > 0 THEN DEC((FLOAT(COMP_PROC_TIME) / FLOAT(COMP_TIME)) * 100,5,1) ELSE NULL END AS COMPILE_PROC_PCT, CASE WHEN IMP_C_TIME > 0 THEN DEC((FLOAT(IMP_C_PROC_TIME) / FLOAT(IMP_C_TIME)) * 100,5,1) ELSE NULL END AS IMPL_COMPILE_PROC_PCT, CASE WHEN ROLLBACK_TIME > 0 THEN DEC((FLOAT(ROLLBACK_PROC_TIME) / FLOAT(ROLLBACK_TIME)) * 100,5,1) ELSE NULL END AS ROLLBACK_PROC_PCT, CASE WHEN COMMIT_TIME > 0 THEN DEC((FLOAT(COMMIT_PROC_TIME) / FLOAT(COMMIT_TIME)) * 100,5,1) ELSE NULL END AS COMMIT_PROC_PCT, CASE WHEN RUNSTATS_TIME > 0 THEN DEC((FLOAT(RUNSTATS_PROC_TIME) / FLOAT(RUNSTATS_TIME)) * 100,5,1) ELSE NULL END AS RUNSTATS_PROC_PCT, CASE WHEN REORG_TIME > 0 THEN DEC((FLOAT(REORG_PROC_TIME) / FLOAT(REORG_TIME)) * 100,5,1) ELSE NULL END AS REORG_PROC_PCT, CASE WHEN LOAD_TIME > 0 THEN DEC((FLOAT(LOAD_PROC_TIME) / FLOAT(LOAD_TIME)) * 100,5,1) ELSE NULL END AS LOAD_PROC_PCT FROM PCTPROC
SECT_PROC_PCT COMPILE_PROC_PCT IMPL_COMPILE_PROC_PCT ROLLBACK_PROC_PCT COMMIT_PROC_PCT RUNSTATS_PROC_PCT REORG_PROC_PCT LOAD_PROC_PCT ------------- ---------------- --------------------- ----------------- --------------- ----------------- -------------- ------------- 57.6 0.1 - 96.9 95.6 0.0 71.1 84.6 1 record(s) selected.
A graphical representation of this data might look something like what is shown in Figure 1:Figure 1. Component processing times as a percentage of overall time spent - Example 4: Ranking time-spent monitor elements
- In the preceding examples, all monitor elements that are displayed are specified explicitly in the SQL for the query; each appears in its own column in the query results. However, there might be times when you do not know which time spent monitor elements you want to examine, such as if you want to see the top ten wait-time monitor elements, or only the non-zero time-spent monitor elements.