IBM Query Tuner Report

This report contains a summary of the recommendations from the Query Tuner advisors and tools. Examine the recommendations and corresponding DDL scripts, if applicable, and take appropriate actions to tune your query. You can also examine the formatted query and access plan summary, and cross reference the recommendations generated by the advisors. Use the catalog table, column, and index information to do further analysis and tuning. Navigate to the different sections using the action buttons and then return to the top of the report using Back to top.



Overview

Recommendation generation timestamp: 2009-08-27T16:12:32
Database server configuration: jdbc:db2://dtec267.svldev.svl.ibm.com:446/STLEC1 (DSN09015)
Estimated plan cost: 7.444 units
Critical problems: 1 statistics recommendations, 0 index recommendations, 0 query recommendations, and 1 access path warnings.
Best practices: 1 statistics recommendations, 0 index recommendations, 2 query recommendations, and 2 access path warnings.

Advice Number Advice Type Tuning Recommendation Description
1 Statistics CRITICAL: Repair statistics: Query Tuner found problems with the repair statistics for this query. Use RUNSTATS to gather missing statistics. Recollect conflicting statistics and potential obsolete statistics. Collect statistics for potential data skew and data correlation problems. Important: if statistics are missing, Query tuner estimates subsequent recommendations based on database default statistics. Click here to review the recommended RUNSTATS script.
5 Access path CRITICAL: Avoid reading all index keys on an index scan (QBLOCKNO = 1, PLANNO = 2). The table DSN8910.EMP is accessed by a non-matching index scan (QBLOCKNO = 1, PLANNO = 2). If a table is accessed by non-matching index scan, then all the index keys and their RIDs are read. When a large number of keys and RIDs are accessed, DB2 might be using an inefficient access path. Consider run the statistics advisor or run the index advisor to determine whether creating an index might improve the access path.Click here to see the access plan operator.
2 Statistics Consolidate statistics: Use RUNSTATS to recollect all the relevant statistics for this query for an accurate evaluation Important: if statistics are missing, Query tuner estimates subsequent recommendations based on database default statistics. Click here to review the recommended RUNSTATS script.
3 Query Avoid the Cartesian join between table DSN8910.EMP and DSN8910.DEPT. Consider adding join predicates between columns EMPNO in table DSN8910.EMP and columns MGRNO in table DSN8910.DEPT to avoid a potentially costly Cartesian join. There is a referential constraint between these two tables. Click here to see the affected query text.
4 Query Provide a predicate on column WORKDEPT. Consider adding the following predicate to column WORKDEPT in table DSN8910.EMP: WORKDEPT IS NOT NULL to filter the table earlier and unlock more possible join sequences.Click here to see the affected query text.
6 Access path Avoid reading all index keys on an index scan (QBLOCKNO = 1, PLANNO = 1). The table DSN8910.EPROJ is accessed by a non-matching index scan (QBLOCKNO = 1, PLANNO = 1). If a table is accessed by non-matching index scan, then all the index keys and their RIDs are read. When a large number of keys and RIDs are accessed, DB2 might be using an inefficient access path. Consider run the statistics advisor or run the index advisor to determine whether creating an index might improve the access path.Click here to see the access plan operator.
7 Access path Avoid sorting (QBLOCKNO = 1, PLANNO = 4) on a large number of records. A sort is used. When a large number of records are returned before sorting, DB2 might be using an inefficient access path. Consider rewriting the query or designing an index to avoid the sort if possible.

Back to top



Recommended Action

The tuning advisors recommend the following actions to update the table and index statistics, and to create the necessary indexes to improve the query performance.



Update Statistics Statements

Advice Number Statement Number Statement Text
1 1 RUNSTATS TABLESPACE "DSN8D91A"."DSN8S91R" INDEX("DB2OE"."EPROJ_VIRT_IDX_1239989173219") SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
2 2 RUNSTATS TABLESPACE "DSN8D91A"."DSN8S91R" INDEX("DB2OE"."EPROJ_VIRT_IDX_1239989173219") SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
2 3 RUNSTATS TABLESPACE "DSN8D91A"."DSN8S91D" INDEX("DSN8910"."XDEPT1", "DSN8910"."XDEPT2" FREQVAL NUMCOLS 1 COUNT 1, "DSN8910"."XDEPT3", "DB2OE"."DEPT_VIRT_IDX_1239989173219" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
2 4 RUNSTATS TABLESPACE "DSN8D91A"."DSN8S91E" INDEX("DSN8910"."XEMP1", "DSN8910"."XEMP2", "DB2OE"."EMP_VIRT_IDX_1239989173219" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE

Back to recommended action


Create Index Statements

Advice Number Statement Number Statement Text

Back to recommended action

Back to top



SQL Statement

Input Query


SELECT A.EMPNO
     , A.FIRSTNME
     , A.LASTNAME
     , A.JOB
     , A.SALARY
     , A.BONUS
     , A.COMM
     , B.LOCATION
     , C.PROJNAME
    FROM DSN8910.EPROJ AS C
     , DSN8910.DEPT AS B
     , DSN8910.EMP AS A /* WARNING=Advice #3 */
    WHERE ( A.EMPNO IN (
SELECT DSN8910.DEPT.MGRNO
     FROM DSN8910.DEPT
     WHERE DSN8910.DEPT.MGRNO IS NOT NULL
     )
     AND A.WORKDEPT = B.DEPTNO /* WARNING=Advice #4 */
     AND B.DEPTNO = C.DEPTNO
     )
    ORDER BY A.EMPNO ASC
     , A.FIRSTNME ASC
     , A.LASTNAME ASC

Back to top



Access Plan Summary

The following table summarizes the access plan's estimated return rows, estimated costs, the total number of table scan, index scan, join and sort operations, total number of predicates, explain timestamp, total number of referenced catalog tables and catalog index usage with percentage of catalog indexes used and percentage of catalog indexes not used. You can examine the table and index scan details and the table access and join predicates being applied.
Note: Subselect (QBLOCK) is available for DB2 for z/OS only.

Subselect (QBLOCK) Estimated Return Rows Estimated Cost Plan Operator Totals Explain Timestamp Referenced Catalog Tables Catalog Index Usage
Total Cost Total CPU Total IO Table Scan Index Scan Join Sort Predicate Used Indexes (%) Unused Indexes (%) Existing Indexes
2 0.000 7.444 8.000 1.087 0 4 2 1 9 2009-08-27T16:12:03 3 4 (50.0%) 4 (50.0%) 8




Database server transformed query for access plan



SELECT A.EMPNO
     , A.FIRSTNME
     , A.LASTNAME
     , A.JOB
     , A.SALARY
     , A.BONUS
     , A.COMM
     , B.LOCATION
     , C.PROJNAME
    FROM DSN8910.EPROJ AS C
     , DSN8910.DEPT AS B
     , DSN8910.EMP AS A
    WHERE ( A.WORKDEPT = B.DEPTNO
     AND A.WORKDEPT = C.DEPTNO
     AND B.DEPTNO = C.DEPTNO
AND A.EMPNO = SYSADM."DSNWFQB(02)".MGRNO
SELECT DSN8910.DEPT.MGRNO
     FROM DSN8910.DEPT
     WHERE ( DSN8910.DEPT.MGRNO IS NOT NULL
     AND A.EMPNO = DSN8910.DEPT.MGRNO
     )
    
     )
    ORDER BY A.EMPNO ASC
     , A.FIRSTNME ASC
     , A.LASTNAME ASC

Back to access plan summary

Predicate for Table Access and Join

Predicates can disqualify rows and reduce the amount of required processing at later stage. The earlier DB2 can evaluate a predicate, the more the query performance can improve. When possible, try to write queries that evaluate the most restrictive predicates first. When predicates with a high filter factor are processed first, unnecessary rows are disqualified as early as possible, which can reduce processing cost at a later stage. Filter factors affect the choice of access paths by estimating the number of rows that qualified by a set of predicates.
Platform Tip: The Query block identifier and plan identifier are available on DB2 for z/OS only.

Query Block: Plan Identifier* Predicate Identifier Predicate Text Used in Join Used in Index Scan Used in Table Scan Filter Factor
1:2 9 A.WORKDEPT=C.DEPTNO Yes No No 0.125000
1:3 3 B.DEPTNO=C.DEPTNO Yes Yes No 0.071429
2:1 5 DSN8910.DEPT.MGRNO IS NOT NULL No No No 0.571429
2:1 8 A.EMPNO=DSN8910.DEPT.MGRNO No Yes No 0.023810

Back to access plan summary

Table Access

Each time a table is accessed by the query, multiple predicate can be applied. For DB2 z/OS, the estimated costs are displayed at the mini plan level and there is no estimated cost available for index access when the value is "N".
Tip: The operator identifier is represented by an Operator ID for DB2 for Linux, UNIX, and Windows, and by "Query block: Plan ID" for DB2 for z/OS.

Operator Identifier** Table Name (Correlation ID) Index Access Estimated Qualified Rows Cumulative Total Cost Cumulative CPU Cost Cumulative IO Cost Predicate ID (How is applied) Advice Number
1:1 DSN8910.EPROJ 
(C)
DB2OE.EPROJ_VIRT_IDX_1239989173219 1.000 0.376 9,890.000 0.000 - 6
1:2 DSN8910.EMP 
(A)
DB2OE.EMP_VIRT_IDX_1239989173219 5.250 1.097 28,864.992 0.000
  • 9 (Stage 1)
5
1:3 DSN8910.DEPT 
(B)
DSN8910.XDEPT1 1.000 2.687 68,228.560 0.047
  • 3 (Matching)
-
2:1 DSN8910.DEPT DSN8910.XDEPT2 0.333 0.239 6,281.902 0.000
  • 5 (Stage 1)
  • 8 (Matching)
-

Back to access plan summary

Join Operation

Each table scan can be used with multiple predicate identifiers. On DB2 for z/OS, the estimated costs are displayed at the plan level.
Tip: the join identifier is represented by an operator ID for DB2 for Linux, UNIX, and Windows, and by a "Query Block: Plan ID" for DB2 for z/OS.

Join Identifier** Join Left Operand Join Right Operand Join Method Is Join Data Sorted Estimated Qualified Rows Cumulative Total Cost Cumulative CPU Cost Cumulative IO Cost Predicate Identifier Advice Number
1:3 DSN8910.EMP
(Correlation ID=A)
DSN8910.DEPT
(Correlation ID=B)
NLJOIN No 1.000 2.687 68,228.560 0.047 3 -
1:2 DSN8910.EPROJ
(Correlation ID=C)
DSN8910.EMP
(Correlation ID=A)
NLJOIN No 5.250 1.097 28,864.992 0.000 9 -

Back to access plan summary

Back to top

Method for applying the predicate.



Table and Index Catalog Information

The following list displays the referenced table statistics in the query access plan. All columns and indexes for the referenced tables are also listed. You can examine the table size, associated primary and foreign keys, cardinality and index columns information; and use the table and index statistics to plan for and reorganize tables and indexes with the REORG utility.

There are 3 referenced tables, 4 used indexes (50.0%), 4 unused indexes (50.0%), and a total of 8 indexes.


Referenced tables, sorted by table name.

**Tablespace name, qualified with database name when on a DB2 for z/OS data server.

Table Name Tablespace Name Foreign Key -> Parent Key Number of Columns Table Cardinality Number of Pages Average Row Size Stats Last Updated
DSN8910.DEPT DSN8D91A.DSN8S91D 5 14 1 56 2005-09-20T17:57:10
DSN8910.EMP DSN8D91A.DSN8S91E 14 42 2 81 2005-09-20T17:58:04
DSN8910.EPROJ DSN8D91A.DSN8S91R - 10 0 0 0 2009-08-18T18:45:13

Back to table and index catalog info

All table columns, sorted by table name and physical column order

Table Name Column Number Column Name Column Type Length Nullable Column Cardinality
DSN8910.DEPT 1 DEPTNO CHAR 3 N 14
  2 DEPTNAME VARCHAR 36 N -1
  3 MGRNO CHAR 6 Y 9
  4 ADMRDEPT CHAR 3 N 3
  5 LOCATION CHAR 16 Y -1
DSN8910.EMP 1 EMPNO CHAR 6 N 42
  2 FIRSTNME VARCHAR 12 N -1
  3 MIDINIT CHAR 1 N -1
  4 LASTNAME VARCHAR 15 N -1
  5 WORKDEPT CHAR 3 Y 8
  6 PHONENO CHAR 4 Y -1
  7 HIREDATE DATE 4 Y -1
  8 JOB CHAR 8 Y -1
  9 EDLEVEL SMALLINT 2 Y -1
  10 SEX CHAR 1 Y -1
  11 BIRTHDATE DATE 4 Y -1
  12 SALARY DECIMAL (9,2) Y -1
  13 BONUS DECIMAL (9,2) Y -1
  14 COMM DECIMAL (9,2) Y -1
DSN8910.EPROJ 1 PROJNO CHAR 6 N -1
  2 PROJNAME VARCHAR 24 N -1
  3 DEPTNO CHAR 3 N 0
  4 RESPEMP CHAR 6 N -1
  5 PRSTAFF DECIMAL (5,2) Y -1
  6 PRSTDATE DATE 4 Y -1
  7 PRENDATE DATE 4 Y -1
  8 MAJPROJ CHAR 6 Y -1
  9 RID CHAR 4 Y -1
  10 TSTAMP TIMESTMP 10 Y -1

Back to table and index catalog info

All indexes, sorted by table name, referenced index name, unreferenced index name, and key column sequence

Table Name Index Name Index Type Unique Rule Used in Plan Leaf Pages Index Levels Cluster Ratio (%) Clustering First Key Cardinality Full Key Cardinality Key Column Key Order Column Cardinality Statistics Last Updated
DSN8910.DEPT DSN8910.XDEPT1 Type 2 Primary index Yes 1 2 100.0 No 14 14 DEPTNO Asc 14 2009-08-18T18:45:14
  DSN8910.XDEPT2 Type 2 Duplicate allowed Yes 1 2 100.0 No 9 9 MGRNO Asc 9 2009-08-18T18:45:14
  DB2OE.DEPT_VIRT_IDX_1239989173219 Type 2 Duplicate allowed No 1 2 100.0 No 9 14 MGRNO Asc 9 2009-08-18T18:45:14
                      DEPTNO Asc 14 2009-08-18T18:45:14
                      LOCATION Asc -1 2009-08-18T18:45:14
  DSN8910.XDEPT3 Type 2 Duplicate allowed No 1 2 100.0 No 3 3 ADMRDEPT Asc 3 2009-08-18T18:45:14
DSN8910.EMP DB2OE.EMP_VIRT_IDX_1239989173219 Type 2 Duplicate allowed Yes 1 2 97.6 No 42 42 EMPNO Asc 42 2009-08-18T18:45:15
                      FIRSTNME Asc -1 2009-08-18T18:45:15
                      LASTNAME Asc -1 2009-08-18T18:45:15
                      WORKDEPT Asc 8 2009-08-18T18:45:15
                      JOB Asc -1 2009-08-18T18:45:15
                      SALARY Asc -1 2009-08-18T18:45:15
                      BONUS Asc -1 2009-08-18T18:45:15
                      COMM Asc -1 2009-08-18T18:45:15
  DSN8910.XEMP1 Partitioning Primary index No 2 2 100.0 Yes 42 42 EMPNO Asc 42 2009-08-18T18:45:15
  DSN8910.XEMP2 Type 2 Duplicate allowed No 1 2 73.8 No 8 8 WORKDEPT Asc 8 2009-08-18T18:45:15
DSN8910.EPROJ DB2OE.EPROJ_VIRT_IDX_1239989173219 Type 2 Duplicate allowed Yes 0 2 0 No 0 0 DEPTNO Asc 0 2009-08-18T18:45:13
                      PROJNAME Asc -1 2009-08-18T18:45:13

Back to table and index catalog info

Back to top



Query Tuner Report Log

The following log records the runtime information including the client version, server license, and which tuning advisors are used to obtain query tuning recommendations.

Server license entitlement and version: IBM Optim Query Workload Tuner for DB2, Version 2.2
Query Tuner client version: 2.2.0.1
Report completion timestamp: 2009-08-27T16:12:32.


Advisor Run Status
Statistics Success
Index Success
Query Success
Access path Success

Back to top