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-09-10T13:18:27
Database server configuration: jdbc:db2://labec804.svldev.svl.ibm.com:446/STLEC1 (DSN09015)
Estimated plan cost: 27,440,036.086 units
Critical problems: 1 statistics recommendations, 0 index recommendations, 0 query recommendations, and 0 access path warnings.
Best practices: 1 statistics recommendations, 1 index recommendations, 0 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.
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 Index Index recommendation is found for the following tables: SYSADM.LINEITEM. The total estimated disk space required is 9,233.012 MB and the estimated performance improvement is 71.512%. This index recommendation will help improve query performance for sort avoidance. Click here to review the recommended CREATE INDEX DDL script.
4 Access path Avoid scanning many or all data partitions on a data partitioned table SYSADM.LINEITEM. The data partitioned table is accessed by Relational Scan (QBLOCKNO = 1, PLANNO = 1) and there is no proper predicate on the leading partitioning key to filter out some partitions. Consider providing a predicate on the leading partitioning key to reduce the number of data partitions need to be scanned. Click here to see the access plan operator.
5 Access path Avoid sorting (QBLOCKNO = 1, PLANNO = 2) 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 "DB4LINEI"."TSLINEI" TABLE("SYSADM"."LINEITEM") SAMPLE 40 COLUMN("L_SHIPDATE") COLGROUP("L_SHIPDATE") FREQVAL COUNT 15 HISTOGRAM NUMQUANTILES 25 SORTNUM 4 INDEX("SYSADM"."SXL@PKSKOKEPDSQN" KEYCARD, "SYSADM"."PXL@OKSDRFSKEPDC" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE
2 2 RUNSTATS TABLESPACE "DB4LINEI"."TSLINEI" TABLE("SYSADM"."LINEITEM") SAMPLE 40 COLUMN("L_SHIPDATE") COLGROUP("L_SHIPDATE") FREQVAL COUNT 15 HISTOGRAM NUMQUANTILES 25 SORTNUM 4 INDEX("SYSADM"."PXL@OKSDRFSKEPDC" KEYCARD, "SYSADM"."SXL@PKSKOKEPDSQN" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE

Back to recommended action


Create Index Statements

Estimated performance improvement is 71.512%.
Estimated disk space use is 9,233.012 MB.

Advice Number Statement Number Statement Text
3 1 CREATE INDEX "DB2OE"."LINEITEM_VIRT_IDX_1252613899142" ON "SYSADM"."LINEITEM" ( "L_RETURNFLAG" ASC, "L_LINESTATUS" ASC, "L_SHIPDATE" ASC, "L_QUANTITY" ASC, "L_EXTENDEDPRICE" ASC, "L_DISCOUNT" ASC, "L_TAX" ASC) NOT PADDED FREEPAGE 0 PCTFREE 10

Back to recommended action

Back to top



SQL Statement

Input Query


SELECT SYSADM.LINEITEM.L_RETURNFLAG
     , SYSADM.LINEITEM.L_LINESTATUS
     , SUM( SYSADM.LINEITEM.L_QUANTITY ) AS SUM_QTY
     , SUM( SYSADM.LINEITEM.L_EXTENDEDPRICE ) AS SUM_BASE_PRICE
     , SUM( SYSADM.LINEITEM.L_DISCOUNT ) AS SUM_DISCOUNT
     , SUM( SYSADM.LINEITEM.L_TAX ) AS SUM_TAX
     , AVG( SYSADM.LINEITEM.L_QUANTITY ) AS AVG_QTY
     , AVG( SYSADM.LINEITEM.L_EXTENDEDPRICE ) AS AVG_PRICE
     , AVG( SYSADM.LINEITEM.L_DISCOUNT ) AS AVG_DISC
     , COUNT(*) AS COUNT_ORDER
    FROM SYSADM.LINEITEM
    WHERE SYSADM.LINEITEM.L_SHIPDATE <= ( DATE( '2008-12-01' ) - 90 DAYS )
    GROUP BY SYSADM.LINEITEM.L_RETURNFLAG
     , SYSADM.LINEITEM.L_LINESTATUS
    ORDER BY SYSADM.LINEITEM.L_RETURNFLAG ASC
     , SYSADM.LINEITEM.L_LINESTATUS 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 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 6.000 27,440,036.086 23,978,240.000 4,608,288.000 1 0 0 1 1 2009-09-10T13:17:57 1 0 (0.0%) 2 (100.0%) 2




Database server transformed query for access plan



SELECT SYSADM.LINEITEM.L_RETURNFLAG
     , SYSADM.LINEITEM.L_LINESTATUS
     , SUM( SYSADM.LINEITEM.L_QUANTITY ) AS SUM_QTY
     , SUM( SYSADM.LINEITEM.L_EXTENDEDPRICE ) AS SUM_BASE_PRICE
     , SUM( SYSADM.LINEITEM.L_DISCOUNT ) AS SUM_DISCOUNT
     , SUM( SYSADM.LINEITEM.L_TAX ) AS SUM_TAX
     , AVG( SYSADM.LINEITEM.L_QUANTITY ) AS AVG_QTY
     , AVG( SYSADM.LINEITEM.L_EXTENDEDPRICE ) AS AVG_PRICE
     , AVG( SYSADM.LINEITEM.L_DISCOUNT ) AS AVG_DISC
     , COUNT(*) AS COUNT_ORDER
    FROM SYSADM.LINEITEM
    WHERE SYSADM.LINEITEM.L_SHIPDATE <= '2008-09-02'
    GROUP BY SYSADM.LINEITEM.L_RETURNFLAG
     , SYSADM.LINEITEM.L_LINESTATUS
    ORDER BY SYSADM.LINEITEM.L_RETURNFLAG ASC
     , SYSADM.LINEITEM.L_LINESTATUS 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 1 SYSADM.LINEITEM.L_SHIPDATE<='2008-09-02' No No Yes 0.999566

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.LINEITEM - 179,920,224.000 8,312,724.000 155,636,269,000.000 1,199,274.000
  • 1 (Stage 1)
4

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

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 1 referenced tables, 0 used indexes (0.0%), 2 unused indexes (100.0%), and a total of 2 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.LINEITEM DB4LINEI.TSLINEI - 16 179,998,372 0 -1 2009-09-08T15:17:08

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.LINEITEM 1 L_ORDERKEY INTEGER 4 N 45,000,000
  2 L_PARTKEY INTEGER 4 N 6,000,000
  3 L_SUPPKEY INTEGER 4 N 303,104
  4 L_LINENUMBER INTEGER 4 N 7
  5 L_QUANTITY FLOAT 8 N 50
  6 L_EXTENDEDPRICE FLOAT 8 N 2,326,528
  7 L_DISCOUNT FLOAT 8 N 11
  8 L_TAX FLOAT 8 N 9
  9 L_RETURNFLAG CHAR 1 N 3
  10 L_LINESTATUS CHAR 1 N 2
  11 L_SHIPDATE DATE 4 N 2,304
  12 L_COMMITDATE DATE 4 N 2,240
  13 L_RECEIPTDATE DATE 4 N 2,400
  14 L_SHIPINSTRUCT CHAR 25 N 4
  15 L_SHIPMODE CHAR 10 N 7
  16 L_COMMENT VARCHAR 44 N 157,286,400

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.LINEITEM SYSADM.PXL@OKSDRFSKEPDC Type 2 Duplicate allowed No 1747586 3 100.0 Yes 45,000,000 179,998,372 L_ORDERKEY Asc 45,000,000 0001-01-01T00:00:00
                      L_SHIPDATE Asc 2,304 0001-01-01T00:00:00
                      L_RETURNFLAG Asc 3 0001-01-01T00:00:00
                      L_SUPPKEY Asc 303,104 0001-01-01T00:00:00
                      L_EXTENDEDPRICE Asc 2,326,528 0001-01-01T00:00:00
                      L_DISCOUNT Asc 11 0001-01-01T00:00:00
  SYSADM.SXL@PKSKOKEPDSQN Type 2 Duplicate allowed No 2195103 4 50.0 No 6,000,000 179,998,372 L_PARTKEY Asc 6,000,000 0001-01-01T00:00:00
                      L_SUPPKEY Asc 303,104 0001-01-01T00:00:00
                      L_ORDERKEY Asc 45,000,000 0001-01-01T00:00:00
                      L_EXTENDEDPRICE Asc 2,326,528 0001-01-01T00:00:00
                      L_DISCOUNT Asc 11 0001-01-01T00:00:00
                      L_QUANTITY Asc 50 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-09-10T13:18:28.


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

Back to top