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:25:26
Database server configuration: jdbc:db2://dtec267.svldev.svl.ibm.com:446/STLEC1 (DSN09015)
Estimated plan cost: 14,122,317.275 units
Critical problems: 1 statistics recommendations, 0 index recommendations, 0 query recommendations, and 2 access path warnings.
Best practices: 1 statistics recommendations, 0 index recommendations, 1 query recommendations, and 3 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.
4 Access path CRITICAL: Avoid joining two tables without a join predicate in nested loop join (QBLOCKNO = 1, PLANNO = 3). The optimizer chooses a join sequence that contains an inner table SYSADM.PARTX without join predicates to any of the outer tables. When a large number of records are returned, DB2 might be using an inefficient access path. Consider providing an appropriate join predicate.Click here to see the access plan operator.
5 Access path CRITICAL: Avoid reading all index keys on an index scan (QBLOCKNO = 1, PLANNO = 3). The table SYSADM.PARTX is accessed by a non-matching index scan (QBLOCKNO = 1, PLANNO = 3). 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 a Cartesian join between table SYSADM.PARTX and other tables. No join predicate exists between table SYSADM.PARTX and other tables. Consider adding join predicates for table SYSADM.PARTX to avoid a costly Cartesian join.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 SYSADM.PARTSUPP 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 Consider providing indexable predicates on columns P_TYPE. A matching index scan (QBLOCKNO = 1, PLANNO = 2) is used to access the table SYSADM.PART, but the predicates do not reference key columns P_TYPE. If these missing key columns were referenced in indexable predicates, DB2 might be able to further narrow the index tree search ranges. Click here to see the access plan operator.
8 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 "DB4PART"."TSPARTX" INDEX("SYSADM"."PXX$PKPTPN" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
1 2 RUNSTATS TABLESPACE "DB4PSUPP"."TSPSUPP" TABLE("SYSADM"."PARTSUPP") SAMPLE 40 COLUMN("PS_AVAILQTY") COLGROUP("PS_AVAILQTY") FREQVAL COUNT 15 SORTNUM 4 INDEX("SYSADM"."PXPS@PKSKSC" KEYCARD FREQVAL NUMCOLS 1 COUNT 15, "SYSADM"."UXPS@SKPKSCAQ" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
1 3 RUNSTATS INDEX("SYSADM"."UXP@SZPTPKMF" KEYCARD, "SYSADM"."PXP@PKPTPN" KEYCARD FREQVAL NUMCOLS 1 COUNT 15) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
2 4 RUNSTATS TABLESPACE "DB4PSUPP"."TSPSUPP" TABLE("SYSADM"."PARTSUPP") SAMPLE 40 COLUMN("PS_AVAILQTY") COLGROUP("PS_AVAILQTY") FREQVAL COUNT 15 SORTNUM 4 INDEX("SYSADM"."PXPS@PKSKSC" KEYCARD FREQVAL NUMCOLS 1 COUNT 15, "SYSADM"."UXPS@SKPKSCAQ" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
2 5 RUNSTATS TABLESPACE "DB4PART"."TSPARTX" INDEX("SYSADM"."PXX$PKPTPN" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
2 6 RUNSTATS TABLESPACE "DB4PART"."TSPART" TABLE("SYSADM"."PART") SAMPLE 40 COLUMN("P_NAME") INDEX("SYSADM"."UXP@SZPTPKMF" KEYCARD, "SYSADM"."PXP@PKPTPN" KEYCARD FREQVAL NUMCOLS 1 COUNT 15) 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 SYSADM.PART.P_NAME
     , SUM( SYSADM.PARTSUPP.PS_AVAILQTY )
     , COUNT(*)
    FROM SYSADM.PARTSUPP
     , SYSADM.PARTX /* WARNING=Advice #3 */
     , SYSADM.PART
    WHERE ( SYSADM.PART.P_NAME LIKE '%green%'
     AND SYSADM.PARTSUPP.PS_AVAILQTY IN ( 3, 5, 9 )
     AND SYSADM.PARTX.PX_RETAILPRICE < ( SYSADM.PART.P_RETAILPRICE - 10 )
     AND SYSADM.PART.P_PARTKEY = SYSADM.PARTSUPP.PS_PARTKEY
     )
    GROUP BY SYSADM.PART.P_NAME
    ORDER BY SYSADM.PART.P_NAME 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
1 6,000,000.000 14,122,317.275 6,901,275.000 1,247,590.000 0 3 2 1 5 2009-08-27T16:25:05 3 3 (60.0%) 2 (40.0%) 5




Database server transformed query for access plan



SELECT SYSADM.PART.P_NAME
     , SUM( SYSADM.PARTSUPP.PS_AVAILQTY )
     , COUNT(*)
    FROM SYSADM.PARTSUPP
     , SYSADM.PARTX
     , SYSADM.PART
    WHERE ( SYSADM.PART.P_NAME LIKE '%green%'
     AND SYSADM.PARTSUPP.PS_AVAILQTY IN ( 3, 5, 9 )
     AND SYSADM.PARTX.PX_RETAILPRICE < CAST( ( SYSADM.PART.P_RETAILPRICE - 10 ) AS FLOAT(0,8) )
     AND SYSADM.PART.P_PARTKEY = SYSADM.PARTSUPP.PS_PARTKEY
     )
    GROUP BY SYSADM.PART.P_NAME
    ORDER BY SYSADM.PART.P_NAME 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:1 5 SYSADM.PARTSUPP.PS_AVAILQTY IN (3,5,9) No Yes No 0.000297
1:2 2 SYSADM.PART.P_PARTKEY=SYSADM.PARTSUPP.PS_PARTKEY Yes Yes No 0.000000
1:2 3 SYSADM.PART.P_NAME LIKE '%green%' No No No 0.086149
1:3 4 SYSADM.PARTX.PX_RETAILPRICE< CAST((SYSADM.PART.P_RETAILPRICE-10) AS FLOAT(0,8)) No No No 0.333333

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 SYSADM.PARTSUPP SYSADM.UXPS@SKPKSCAQ 7,120.242 213,560.440 3,865,570,300.000 33,334.400
  • 5 (Screening)
6
1:2 SYSADM.PART SYSADM.PXP@PKPTPN 1.000 232,200.440 3,968,116,990.000 40,706.035
  • 2 (Matching)
7
1:3 SYSADM.PARTX SYSADM.PXX$PKPTPN 3,333.333 11,229,119.000 74,839,228,000.000 4,192,614.000 - 5

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 SYSADM.PART
(Operator ID=1:2)
SYSADM.PARTX
(Operator ID=1:3)
NLJOIN No 3,333.333 11,229,119.000 74,839,228,000.000 4,192,614.000 - -
1:2 SYSADM.PARTSUPP
(Operator ID=1:1)
SYSADM.PART
(Operator ID=1:2)
NLJOIN No 1.000 232,200.440 3,968,116,990.000 40,706.035 2 -

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, 3 used indexes (60.0%), 2 unused indexes (40.0%), and a total of 5 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
SYSADM.PART DB4PART.TSPART - 9 6,000,000 0 -1 0001-01-01T00:00:00
SYSADM.PARTSUPP DB4PSUPP.TSPSUPP - 5 24,000,000 0 -1 0001-01-01T00:00:00
SYSADM.PARTX DB4PART.TSPARTX - 15 -1 -1 -1 0001-01-01T00:00:00

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
SYSADM.PART 1 P_PARTKEY INTEGER 4 N 6,000,000
  2 P_NAME VARCHAR 55 N 6,000,000
  3 P_MFGR CHAR 25 N 5
  4 P_BRAND CHAR 10 N 25
  5 P_TYPE VARCHAR 25 N 150
  6 P_SIZE INTEGER 4 N 50
  7 P_CONTAINER CHAR 10 N 40
  8 P_RETAILPRICE FLOAT 8 N 58,368
  9 P_COMMENT VARCHAR 23 N 5,111,808
SYSADM.PARTSUPP 1 PS_PARTKEY INTEGER 4 N 6,000,000
  2 PS_SUPPKEY INTEGER 4 N 300,000
  3 PS_AVAILQTY INTEGER 4 N 10,112
  4 PS_SUPPLYCOST FLOAT 8 N 94,208
  5 PS_COMMENT VARCHAR 199 N 21,233,664
SYSADM.PARTX 1 PX_PARTKEY INTEGER 4 N -1
  2 PX_NAME VARCHAR 55 N -1
  3 PX_MFGR CHAR 25 N -1
  4 PX_BRAND CHAR 10 N -1
  5 PX_BRAND_C10 CHAR 10 N -1
  6 PX_BRAND_C20 CHAR 20 N -1
  7 PX_BRAND_V10 VARCHAR 10 N -1
  8 PX_BRAND_V20 VARCHAR 20 N -1
  9 PX_TYPE VARCHAR 25 N -1
  10 PX_TYPE_V30 VARCHAR 30 N -1
  11 PX_SIZE INTEGER 4 N -1
  12 PX_CONTAINER CHAR 10 N -1
  13 PX_CONTAINER_V10 VARCHAR 10 N -1
  14 PX_RETAILPRICE FLOAT 8 N -1
  15 PX_COMMENT VARCHAR 23 N -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
SYSADM.PART SYSADM.PXP@PKPTPN Type 2 Unique index Yes 139560 3 100.0 Yes 6,000,000 6,000,000 P_PARTKEY Asc 6,000,000 0001-01-01T00:00:00
                      P_TYPE Asc 150 0001-01-01T00:00:00
                      P_NAME Asc 6,000,000 0001-01-01T00:00:00
  SYSADM.UXP@SZPTPKMF Type 2 Unique index No 98361 4 53.0 No 50 6,000,000 P_SIZE Asc 50 0001-01-01T00:00:00
                      P_TYPE Asc 150 0001-01-01T00:00:00
                      P_PARTKEY Asc 6,000,000 0001-01-01T00:00:00
                      P_MFGR Asc 5 0001-01-01T00:00:00
SYSADM.PARTSUPP SYSADM.UXPS@SKPKSCAQ Type 2 Unique index Yes 166667 4 50.0 No 300,000 24,000,000 PS_SUPPKEY Asc 300,000 0001-01-01T00:00:00
                      PS_PARTKEY Asc 6,000,000 0001-01-01T00:00:00
                      PS_SUPPLYCOST Asc 94,208 0001-01-01T00:00:00
                      PS_AVAILQTY Asc 10,112 0001-01-01T00:00:00
  SYSADM.PXPS@PKSKSC Type 2 Unique index No 142860 3 100.0 Yes 6,000,000 24,000,000 PS_PARTKEY Asc 6,000,000 0001-01-01T00:00:00
                      PS_SUPPKEY Asc 300,000 0001-01-01T00:00:00
                      PS_SUPPLYCOST Asc 94,208 0001-01-01T00:00:00
SYSADM.PARTX SYSADM.PXX$PKPTPN Type 2 Unique index Yes -1 -1 0 Yes -1 -1 PX_PARTKEY Asc -1 0001-01-01T00:00:00
                      PX_TYPE Asc -1 0001-01-01T00:00:00
                      PX_NAME Asc -1 0001-01-01T00:00:00

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:25:26.


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

Back to top