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 cataloged 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-27T14:00:50
Database server configuration: jdbc:db2://9.30.68.24:50000/TPCD (SQL09051)
Estimated plan cost: 9,394.931 units
Critical problems: 1 statistics recommendations, 0 index recommendations, 0 query recommendations, and 0 access path warnings.
Best practices: 0 statistics recommendations, 0 index recommendations, 1 query recommendations, and 0 access path warnings.

Advice Number Advice Type Tuning Recommendation Description
1 Statistics CRITICAL: 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.
2 Query Provide a predicate on column SR_RETURNED_DATE_SK. Consider adding the following predicate to column SR_RETURNED_DATE_SK in table STORE_RETURNS: SR_RETURNED_DATE_SK IS NOT NULL to filter the table earlier and unlock more possible join sequences.Click here to see the affected query text.

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 ON TABLE "TPCDS"."STORE_RETURNS" WITH DISTRIBUTION ON COLUMNS ( "SR_RETURNED_DATE_SK" NUM_FREQVALUES 15 NUM_QUANTILES 25 ) AND SAMPLED DETAILED INDEXES ALL ALLOW WRITE ACCESS
1 2 RUNSTATS ON TABLE "TPCDS"."DATE_DIM" ON COLUMNS ( "D_DATE_SK" ) WITH DISTRIBUTION ON COLUMNS ( "D_YEAR" NUM_FREQVALUES 15 NUM_QUANTILES 25 ) AND SAMPLED DETAILED INDEXES ALL ALLOW WRITE ACCESS

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 TPCDS.STORE_RETURNS.SR_CUSTOMER_SK AS CTR_CUSTOMER_SK
     , TPCDS.STORE_RETURNS.SR_STORE_SK AS CTR_STORE_SK
     , SUM(TPCDS.STORE_RETURNS.SR_RETURN_AMT) AS CTR_TOTAL_RETURN
    FROM TPCDS.STORE_RETURNS /* no. of rows=287607 */
     , TPCDS.DATE_DIM /* no. of rows=73049 */
    WHERE TPCDS.DATE_DIM.D_YEAR = 2009
     AND TPCDS.STORE_RETURNS.SR_RETURNED_DATE_SK = TPCDS.DATE_DIM.D_DATE_SK /* WARNING=Advice #2 */
    GROUP BY TPCDS.STORE_RETURNS.SR_CUSTOMER_SK,
     TPCDS.STORE_RETURNS.SR_STORE_SK

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 cataloged tables referenced and the index usage with percentage of indexes used and percentage of 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 Cataloged Tables Referenced Catalog Index Usage
Total Cost Total CPU Total IO Table Scan Index Scan Join Sort Predicate Used Indexes (%) Unused Indexes (%) Existing Indexes
- 1,430.064 9,394.931 19,584,794.000 729.365 0 2 1 1 2 2009-08-27T14:00:13 2 2 (40.0%) 3 (60.0%) 5




Database server transformed query for access plan


SELECT  Q4.$C0  AS  "CTR_CUSTOMER_SK", 
     Q4.$C1  AS  "CTR_STORE_SK", 
     Q4.$C2  AS  "CTR_TOTAL_RETURN" 
FROM  (SELECT  Q3.$C0, 
     Q3.$C1, 
     SUM(Q3.$C2) 
FROM  (SELECT  Q2.SR_CUSTOMER_SK, 
     Q2.SR_STORE_SK, 
     Q2.SR_RETURN_AMT 
FROM  TPCDS.DATE_DIM  AS  Q1, 
     TPCDS.STORE_RETURNS  AS  Q2 
WHERE  (Q1.D_YEAR  =  2009) 
AND  (Q2.SR_RETURNED_DATE_SK  =  Q1.D_DATE_SK))  AS  Q3 
GROUP  BY  Q3.$C1, 
     Q3.$C0)  AS  Q4 

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
- 4 (Q1.D_YEAR = 2009) No Yes No 0.004972
- 5 (Q2.SR_RETURNED_DATE_SK = Q1.D_DATE_SK) Yes Yes No 0.000014

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
6 TPCDS.DATE_DIM 
(Q1)
DB2OE.IDX904292302380000 363.220 38.395 708,914.938 2.924
  • 4 (START, STOP)
-
7 TPCDS.STORE_RETURNS 
(Q2)
DB2OE.IDX904292303140000 3.937 25.796 83,294.188 2.000
  • 5 (START, STOP)
-

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
5 TPCDS.DATE_DIM
(Correlation ID=Q1)
TPCDS.STORE_RETURNS
(Correlation ID=Q2)
NLJOIN No 1,430.064 9,389.229 14,641,049.000 729.365 5 -

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 2 referenced tables, 2 used indexes (40.0%), 3 unused indexes (60.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
TPCDS.DATE_DIM USERSPACE1 - 28 73,049 2,150 117 2009-08-19T12:28:46
TPCDS.STORE_RETURNS USERSPACE1 20 287,607 7,778 108 2009-04-29T15:59: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
TPCDS.DATE_DIM 0 D_DATE_SK INTEGER 4 N 73049.0
  1 D_DATE_ID CHARACTER 16 N -1.0
  2 D_DATE DATE 4 N -1.0
  3 D_MONTH_SEQ INTEGER 4 N -1.0
  4 D_WEEK_SEQ INTEGER 4 N -1.0
  5 D_QUARTER_SEQ INTEGER 4 N -1.0
  6 D_YEAR INTEGER 4 N 201.0
  7 D_DOW INTEGER 4 N -1.0
  8 D_MOY INTEGER 4 N 12.0
  9 D_DOM INTEGER 4 N -1.0
  10 D_QOY INTEGER 4 N -1.0
  11 D_FY_YEAR INTEGER 4 N -1.0
  12 D_FY_QUARTER_SEQ INTEGER 4 N -1.0
  13 D_FY_WEEK_SEQ INTEGER 4 N -1.0
  14 D_DAY_NAME CHARACTER 9 N -1.0
  15 D_QUARTER_NAME CHARACTER 6 N -1.0
  16 D_HOLIDAY CHARACTER 1 N -1.0
  17 D_WEEKEND CHARACTER 1 N -1.0
  18 D_FOLLOWING_HOLIDAY CHARACTER 1 N -1.0
  19 D_FIRST_DOM INTEGER 4 N -1.0
  20 D_LAST_DOM INTEGER 4 N -1.0
  21 D_SAME_DAY_LY INTEGER 4 N -1.0
  22 D_SAME_DAY_LQ INTEGER 4 N -1.0
  23 D_CURRENT_DAY CHARACTER 1 N -1.0
  24 D_CURRENT_WEEK CHARACTER 1 N -1.0
  25 D_CURRENT_MONTH CHARACTER 1 N -1.0
  26 D_CURRENT_QUARTER CHARACTER 1 N -1.0
  27 D_CURRENT_YEAR CHARACTER 1 N -1.0
TPCDS.STORE_RETURNS 0 SR_RETURNED_DATE_SK INTEGER 4 Y 1985.0
  1 SR_RETURN_TIME_SK INTEGER 4 Y 32257.0
  2 SR_ITEM_SK INTEGER 4 N 18000.0
  3 SR_CUSTOMER_SK INTEGER 4 Y 89089.0
  4 SR_CDEMO_SK INTEGER 4 Y 287607.0
  5 SR_HDEMO_SK INTEGER 4 Y 7169.0
  6 SR_ADDR_SK INTEGER 4 Y 50001.0
  7 SR_STORE_SK INTEGER 4 Y 7.0
  8 SR_REASON_SK INTEGER 4 Y 36.0
  9 SR_TICKET_NUMBER INTEGER 4 N 155648.0
  10 SR_RETURN_QUANTITY INTEGER 4 Y 101.0
  11 SR_RETURN_AMT DECIMAL (7,2) Y 107521.0
  12 SR_RETURN_TAX DECIMAL (7,2) Y 28673.0
  13 SR_RETURN_AMT_INC_TAX DECIMAL (7,2) Y 155649.0
  14 SR_FEE DECIMAL (7,2) Y 10369.0
  15 SR_RETURN_SHIP_COST DECIMAL (7,2) Y 78849.0
  16 SR_REFUNDED_CASH DECIMAL (7,2) Y 103425.0
  17 SR_REVERSED_CHARGE DECIMAL (7,2) Y 78849.0
  18 SR_STORE_CREDIT DECIMAL (7,2) Y 66561.0
  19 SR_NET_LOSS DECIMAL (7,2) Y 107521.0

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
TPCDS.DATE_DIM DB2OE.IDX904292302380000 Regular Duplicate allowed Yes 387 3 -1 No 201 73,049.000 D_YEAR Asc 201.0 2009-08-19T12:28:46
                      D_DATE_SK Asc 73049.0 2009-08-19T12:28:46
  DB2OE.IDX904300112320000 Regular Duplicate allowed No 2436 4 -1 No 201 73,049.000 D_YEAR Asc 201.0 2009-08-19T12:28:46
                      D_LAST_DOM Asc -1.0 2009-08-19T12:28:46
                      D_FIRST_DOM Asc -1.0 2009-08-19T12:28:46
                      D_FOLLOWING_HOLIDAY Asc -1.0 2009-08-19T12:28:46
                      D_WEEKEND Asc -1.0 2009-08-19T12:28:46
                      D_HOLIDAY Asc -1.0 2009-08-19T12:28:46
                      D_QUARTER_NAME Asc -1.0 2009-08-19T12:28:46
                      D_DAY_NAME Asc -1.0 2009-08-19T12:28:46
                      D_FY_WEEK_SEQ Asc -1.0 2009-08-19T12:28:46
                      D_FY_QUARTER_SEQ Asc -1.0 2009-08-19T12:28:46
                      D_FY_YEAR Asc -1.0 2009-08-19T12:28:46
                      D_MOY Asc 12.0 2009-08-19T12:28:46
                      D_QOY Asc -1.0 2009-08-19T12:28:46
                      D_DOM Asc -1.0 2009-08-19T12:28:46
                      D_DOW Asc -1.0 2009-08-19T12:28:46
                      D_QUARTER_SEQ Asc -1.0 2009-08-19T12:28:46
                      D_WEEK_SEQ Asc -1.0 2009-08-19T12:28:46
                      D_MONTH_SEQ Asc -1.0 2009-08-19T12:28:46
                      D_DATE Asc -1.0 2009-08-19T12:28:46
                      D_DATE_ID Asc -1.0 2009-08-19T12:28:46
                      D_DATE_SK Asc 73049.0 2009-08-19T12:28:46
                      D_CURRENT_YEAR Asc -1.0 2009-08-19T12:28:46
                      D_CURRENT_QUARTER Asc -1.0 2009-08-19T12:28:46
                      D_CURRENT_MONTH Asc -1.0 2009-08-19T12:28:46
                      D_CURRENT_WEEK Asc -1.0 2009-08-19T12:28:46
                      D_CURRENT_DAY Asc -1.0 2009-08-19T12:28:46
                      D_SAME_DAY_LQ Asc -1.0 2009-08-19T12:28:46
                      D_SAME_DAY_LY Asc -1.0 2009-08-19T12:28:46
  SYSIBM.SQL090429132201570 Regular Primary index No 305 3 -1 No 73,049.000 73,049.000 D_DATE_SK Asc 73049.0 2009-08-19T12:28:46
TPCDS.STORE_RETURNS DB2OE.IDX904292303140000 Regular Duplicate allowed Yes -1 -1 -1 No -1 -1.000 SR_RETURNED_DATE_SK Asc 1985.0 -
                      SR_CUSTOMER_SK Asc 89089.0 -
                      SR_STORE_SK Asc 7.0 -
                      SR_RETURN_AMT Asc 107521.0 -
  SYSIBM.SQL090429132202870 Regular Primary index No 1522 3 -1 No 17,995.000 287,607.000 SR_ITEM_SK Asc 18000.0 2009-04-29T13:26:03
                      SR_TICKET_NUMBER Asc 155648.0 2009-04-29T13:26:03

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-27T14:00:50.


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

Back to top