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.
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. |
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 StatementsRecommended Action
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 |
Create Index Statements
Estimated performance improvement is 71.512%.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 |
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 |
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 |
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.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 |
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 |
|
4 |
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 |
---|
Method for applying the predicate.
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 |
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 |
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 |
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 |