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.
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 | Query | Provide a predicate on column L_SUPPKEY in table SYSADM.LINEITEM. Consider adding the following predicate on column S_SUPPKEY in table SYSADM.SUPPLIER to column L_SUPPKEY in table SYSADM.LINEITEM: S.S_SUPPKEY IN ( 1 , 22 , 333 , 4444 , 55555 ) so that more unqualified rows from the table can be filtered out earlier.Click here to see the affected query text. |
4 | Query | Avoid an asterisk (*) or a long column list in the SELECT clause. Consider replacing the asterisk (*) or the long column list for table SYSADM.ORDER,SYSADM.SUPPLIER,SYSADM.LINEITEM in the SELECT list with just the names of the required columns.Click here to see the affected query text. |
5 | Access path | Avoid reading all index keys on an index scan (QBLOCKNO = 1, PLANNO = 2). The table SYSADM.LINEITEM 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. |
6 | 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. Click here to see the access plan operator. This Access path recommendation also applies to the following objects. |
7 | - (QBLOCKNO = 1, PLANNO = 3) |
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 INDEX("SYSADM"."PXS@SKNK" FREQVAL NUMCOLS 1 COUNT 15) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE |
1 | 2 | RUNSTATS TABLESPACE "DB4LINEI"."TSLINEI" TABLE("SYSADM"."LINEITEM") SAMPLE 40 COLUMN("L_SHIPMODE") COLGROUP("L_SHIPDATE") HISTOGRAM NUMQUANTILES 25 COLGROUP("L_RECEIPTDATE") FREQVAL COUNT 15 HISTOGRAM NUMQUANTILES 25 COLGROUP("L_SHIPMODE") FREQVAL COUNT 15 COLGROUP("L_RETURNFLAG") FREQVAL COUNT 15 SORTNUM 4 INDEX("SYSADM"."SXL@PKSKOKEPDSQN" KEYCARD, "SYSADM"."PXL@OKSDRFSKEPDC" KEYCARD FREQVAL NUMCOLS 1 COUNT 15) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE |
1 | 3 | RUNSTATS TABLESPACE "DB4ORDER"."TSORDER" TABLE("SYSADM"."ORDER") SAMPLE 40 COLUMN("O_ORDERPRIORITY") COLGROUP("O_ORDERPRIORITY") FREQVAL COUNT 15 SORTNUM 4 INDEX("SYSADM"."PXO@OKODCKSPOP" KEYCARD FREQVAL NUMCOLS 1 COUNT 15, "SYSADM"."UXO#CLOKOD" KEYCARD, "SYSADM"."UXO@CKOKODSP" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE |
2 | 4 | RUNSTATS TABLESPACE "DB4SUPLY"."TSSUPLY" INDEX("SYSADM"."PXS@SKNK" FREQVAL NUMCOLS 1 COUNT 15) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE |
2 | 5 | RUNSTATS TABLESPACE "DB4LINEI"."TSLINEI" TABLE("SYSADM"."LINEITEM") SAMPLE 40 COLUMN("L_SUPPKEY") COLGROUP("L_SHIPDATE") HISTOGRAM NUMQUANTILES 25 COLGROUP("L_RECEIPTDATE") FREQVAL COUNT 15 HISTOGRAM NUMQUANTILES 25 COLGROUP("L_SHIPMODE") FREQVAL COUNT 15 COLGROUP("L_RETURNFLAG") FREQVAL COUNT 15 SORTNUM 4 INDEX("SYSADM"."PXL@OKSDRFSKEPDC" KEYCARD FREQVAL NUMCOLS 1 COUNT 15, "SYSADM"."SXL@PKSKOKEPDSQN" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE |
2 | 6 | RUNSTATS TABLESPACE "DB4ORDER"."TSORDER" TABLE("SYSADM"."ORDER") SAMPLE 40 COLUMN("O_ORDERPRIORITY") COLGROUP("O_ORDERPRIORITY") FREQVAL COUNT 15 SORTNUM 4 INDEX("SYSADM"."PXO@OKODCKSPOP" KEYCARD FREQVAL NUMCOLS 1 COUNT 15, "SYSADM"."UXO#CLOKOD" KEYCARD, "SYSADM"."UXO@CKOKODSP" KEYCARD) SHRLEVEL CHANGE REPORT YES UPDATE ALL HISTORY NONE |
Create Index Statements
Advice Number | Statement Number | Statement Text |
---|
Input Query
SELECT * | ||
FROM SYSADM.SUPPLIER AS S | ||
, SYSADM.LINEITEM AS L | ||
, SYSADM.ORDER AS O | /* WARNING=Advice #4 */ | |
WHERE ( L.L_SHIPDATE BETWEEN '2008-01-01' AND '2008-12-31' | ||
AND L.L_RETURNFLAG IN ( 'A', 'R' ) | ||
AND L.L_SHIPMODE IN ( 'SHIP', 'AIR', 'RAIL', 'TRUCK' ) | ||
AND L.L_RECEIPTDATE <= '2008-12-31' | ||
AND O.O_ORDERPRIORITY IN ( '1-URGENT', '2-HIGH' ) | ||
AND S.S_SUPPKEY IN ( 1, 22, 333, 4444, 55555 ) | /* WARNING=Advice #3 */ | |
AND L.L_ORDERKEY = O.O_ORDERKEY | ||
AND L.L_SUPPKEY = S.S_SUPPKEY | ||
) |
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 | 5.000 | 2,086,459.255 | 1,802,150.000 | 358,411.000 | 0 | 3 | 2 | 2 | 9 | 2009-08-27T16:20:53 | 3 | 3 (50.0%) | 3 (50.0%) | 6 |
Database server transformed query for access plan
SELECT * FROM SYSADM.SUPPLIER AS S , SYSADM.LINEITEM AS L , SYSADM.ORDER AS O WHERE ( L.L_SHIPDATE BETWEEN '2008-01-01' AND '2008-12-31' AND L.L_RETURNFLAG IN ( 'A', 'R' ) AND L.L_SHIPMODE IN ( 'SHIP', 'AIR', 'RAIL', 'TRUCK' ) AND L.L_RECEIPTDATE <= '2008-12-31' AND O.O_ORDERPRIORITY IN ( '1-URGENT', '2-HIGH' ) AND S.S_SUPPKEY IN ( 1, 22, 333, 4444, 55555 ) AND L.L_ORDERKEY = O.O_ORDERKEY AND L.L_SUPPKEY = S.S_SUPPKEY ) |
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 | 6 | S.S_SUPPKEY IN (1,22,333,4444,55555) | No | Yes | No | 0.000017 |
1:2 | 2 | L.L_RECEIPTDATE<='2008-12-31' | No | No | No | 0.999583 |
1:2 | 3 | L.L_SHIPDATE BETWEEN '2008-01-01' AND '2008-12-31' | No | Yes | No | 0.000434 |
1:2 | 4 | L.L_RETURNFLAG IN ('A','R') | No | Yes | No | 0.500000 |
1:2 | 5 | L.L_SHIPMODE IN ('SHIP','AIR','RAIL','TRUCK') | No | No | No | 0.500000 |
1:2 | 8 | L.L_SUPPKEY=S.S_SUPPKEY | Yes | No | No | 0.000003 |
1:3 | 7 | O.O_ORDERPRIORITY IN ('1-URGENT','2-HIGH') | No | Yes | No | 0.400000 |
1:3 | 9 | L.L_ORDERKEY=O.O_ORDERKEY | Yes | Yes | No | 0.000000 |
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.SUPPLIER (S) |
SYSADM.PXS@SKNK | 5.000 | 1.069 | 17,865.805 | 0.195 |
|
- |
1:2 | SYSADM.LINEITEM (L) |
SYSADM.PXL@OKSDRFSKEPDC | 19,523.684 | 2,086,440.000 | 36,042,822,000.000 | 358,407.750 | 6 | |
1:3 | SYSADM.ORDER (O) |
SYSADM.PXO@OKODCKSPOP | 1.000 | 2,086,448.000 | 36,042,920,000.000 | 358,411.000 | 7 |
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.LINEITEM (Correlation ID=L) |
SYSADM.ORDER (Correlation ID=O) |
NLJOIN | outer | 1.000 | 2,086,448.000 | 36,042,920,000.000 | 358,411.000 | 9 | - |
1:2 | SYSADM.SUPPLIER (Correlation ID=S) |
SYSADM.LINEITEM (Correlation ID=L) |
SMJOIN | inner | 19,523.684 | 2,086,440.000 | 36,042,822,000.000 | 358,407.750 | 8 | - |
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 3 referenced tables, 3 used indexes (50.0%), 3 unused indexes (50.0%), and a total of 6 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 | 2008-11-14T16:23:22 |
SYSADM.ORDER | DB4ORDER.TSORDER | - | 9 | 45,000,000 | 0 | -1 | 0001-01-01T00:00:00 |
SYSADM.SUPPLIER | DB4SUPLY.TSSUPLY | - | 7 | 300,000 | 0 | -1 | 0001-01-01T00:00:00 |
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 | |
SYSADM.ORDER | 1 | O_ORDERKEY | INTEGER | 4 | N | 45,000,000 |
2 | O_CUSTKEY | INTEGER | 4 | N | 0 | |
3 | O_ORDERSTATUS | CHAR | 1 | N | 3 | |
4 | O_TOTALPRICE | FLOAT | 8 | N | 23,068,672 | |
5 | O_ORDERDATE | DATE | 4 | N | 2,304 | |
6 | O_ORDERPRIORITY | CHAR | 15 | N | 5 | |
7 | O_CLERK | CHAR | 15 | N | 0 | |
8 | O_SHIPPRIORITY | INTEGER | 4 | N | 1 | |
9 | O_COMMENT | VARCHAR | 79 | N | 42,991,616 | |
SYSADM.SUPPLIER | 1 | S_SUPPKEY | INTEGER | 4 | N | 300,000 |
2 | S_NAME | CHAR | 25 | N | 258,048 | |
3 | S_ADDRESS | VARCHAR | 40 | N | 294,912 | |
4 | S_NATIONKEY | INTEGER | 4 | N | 25 | |
5 | S_PHONE | CHAR | 15 | N | 270,336 | |
6 | S_ACCTBAL | FLOAT | 8 | N | 278,528 | |
7 | S_COMMENT | VARCHAR | 101 | N | 300,000 |
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 | Yes | 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 | |||||||||||
SYSADM.ORDER | SYSADM.PXO@OKODCKSPOP | Type 2 | Unique index | Yes | 436920 | 3 | 100.0 | Yes | 45,000,000 | 45,000,000 | O_ORDERKEY | Asc | 45,000,000 | 0001-01-01T00:00:00 |
O_ORDERDATE | Asc | 2,304 | 0001-01-01T00:00:00 | |||||||||||
O_CUSTKEY | Asc | 0 | 0001-01-01T00:00:00 | |||||||||||
O_SHIPPRIORITY | Asc | 1 | 0001-01-01T00:00:00 | |||||||||||
O_ORDERPRIORITY | Asc | 5 | 0001-01-01T00:00:00 | |||||||||||
SYSADM.UXO#CLOKOD | Type 2 | Unique index | No | 0 | 2 | 0 | No | 0 | 0 | O_CLERK | Asc | 0 | 2009-03-31T12:10:59 | |
O_ORDERKEY | Asc | 45,000,000 | 2009-03-31T12:10:59 | |||||||||||
O_ORDERDATE | Asc | 2,304 | 2009-03-31T12:10:59 | |||||||||||
SYSADM.UXO@CKOKODSP | Type 2 | Unique index | No | 0 | 2 | 0 | No | 0 | 0 | O_CUSTKEY | Asc | 0 | 2009-03-31T12:10:59 | |
O_ORDERKEY | Asc | 45,000,000 | 2009-03-31T12:10:59 | |||||||||||
O_ORDERDATE | Asc | 2,304 | 2009-03-31T12:10:59 | |||||||||||
O_SHIPPRIORITY | Asc | 1 | 2009-03-31T12:10:59 | |||||||||||
SYSADM.SUPPLIER | SYSADM.PXS@SKNK | Type 2 | Unique index | Yes | 1200 | 2 | 100.0 | Yes | 300,000 | 300,000 | S_SUPPKEY | Asc | 300,000 | 0001-01-01T00:00:00 |
S_NATIONKEY | Asc | 25 | 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-08-27T16:21:15.
Advisor | Run Status |
---|---|
Statistics | Success |
Index | Success |
Query | Success |
Access path | Success |