Summary-level messages contain:
Detail-level messages contain cost estimates for each possible combination of join order and method. If you think another join order or method should have a lower cost, you can see the estimates used by the optimizer.
Reference Information
This section identifies the statement and subselect or subquery being optimized and contains a copy of the SQL source statement and index definitions for referenced tables.
Headings and Source Statement
Bind-time messages begin by identifying the statement being bound and listing the SQL statement:
*** Plan:authId.planName, Stmt:nnnnnnnn DT:yyyy.-mm-dd hh:mm:ss xxxxxxxxxxxxxxxxxxxxxxxxxxx source statement xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
One of the following messages identifies the subselect or subquery:
***** BIND MESSAGES FOR SUBSELECT nn ***** ***** BIND MESSAGES FOR SUBQUERY LEVEL nn NUMBER nn OF SUBSELECT nn *****
Subselects are numbered in the order they appear in the SQL statement. Unless you have a UNION, there is only one subselect.
Level 1 is a subquery of a subselect, level 2 a subquery of a level 1 subquery, and so on.
Multiple subqueries in the same search condition are numbered in the order in which they appear in the SQL statement.
Index Definitions
Index definitions are listed as reference information for each base table referenced in the query.
Table Level
INDEX DEFINITIONS FOR: ttt/ddd authId.tableName correlationName KEYS=nn, IDXLVLS=n, LN=nnnnn, ROWS/BLK=nnn ROWS=nnnnnnnnn *** WARNING: INDEX CARDINALITY STATISTICS NOT COMPUTED ***
DATACOM 3-character name and database ID.
Number of keys defined for the table.
Number of levels in the index.
Number of bytes in a row.
Number of rows that can fit in a data block (actual value may be higher for compressed areas).
Number of rows in the table (as reported in the Directory (CXX)).
Join optimization is very dependent on index cardinality. To compute index cardinality, use the CA Datacom/DB Utility (DBUTLTY) to either execute the RETIX or LOAD function, or use:
REPORT AREA=IXX,DBID=nnn,TYPE=G,UPDATE=YES
Key Level
KEY xxxxx id=nnn FLG=hh hh FLDS=nn DXX=nnnn BLKCHG=nnnn ROWS=nnnnnn
CA Datacom/DB five-character key name.
CA Datacom/DB key ID.
Key attributes (as hex dump of bit flags):
Note: Any value found (on a report) that is unobtainable using the values below is for internal use only.
NATIVE SEQUENCE KEY
NIL-INCL-KEY
MASTER KEY
DUPLICATE KEY ID IN THIS FILE
DIFFERENT TOTAL KEY LENGTHS
UNIQUE KEY
KEY HAS DATA TYPE SENSITIVE FIELDS
KEY HAS DECIMAL FIELDS
KEY IS RELATIVE RECORD NUMBER
CBS WILL IGNORE THIS KEY
Number of columns in key
Average number of index entries per DXX block
Average number of data area blocks that must be accessed to read 1024 rows in sequence by this key.
Number of index entries at the time when cardinality was last computed. This can be lower than ROWS at the table level if NIL-INCL-KEY is specified.
Column Level
OFFSET=nnnnn, LN=nnn, DIR=xxxx SENS=x CARDINALITY=nnnnnnnnn xxxxx...
Offset of column in the row, relative to zero
Number of bytes in the column
Either ASC for ascending or DESC for descending direction
Either Y for data type sensitive, or N
Number of unique values for this and preceding columns
SQL column name
Sort Optimization
Each subselect or subquery can require at most two sorts for:
The estimated cost of these sorts is indicated by the following messages:
ESTIMATED GROUP SORT COST= nnnnnnnnn ESTIMATED ORDER/DISTINCT/UNION SORT COST= nnnnnnnnn
If ORDER BY and GROUP BY reference the same columns, SORT1 eliminates the need for SORT2, which is indicated by the following message:
ORDER/DISTINCT/UNION SORT SATISFIED BY GROUP BY SORT
UNION and DISTINCT always require SORT2, but if the scan index returns rows in sort sequence, then sorts for GROUP BY and ORDER BY can be eliminated.
The following messages indicate which indexes, if any, satisfy these sorts.
KEY xxxxx SATISFIES GROUP BY KEY xxxxx SATISFIES ORDER/DISTINCT/UNION
However, if these indexes are to be used to eliminate sorts, they must:
Data Access Plan
The data access plan contains:
Total Estimated Cost
Total estimated cost is given by the first message if there is a join, else by the second message.
TOTAL JOIN COST ESTIMATE = nnnnnnnnn KEY xxxxx HAS LOWEST COST OF nnnnnnnnn FOR nnnnnnnnn ROWS
Join Steps
Messages in this section are only generated when a join exists.
The terms outer and inner table refererence the first and second tables of a join, respectively. When three or more tables are joined, the first two tables are joined, and the result of that join becomes the outer table of the next join, and so on.
Predicates dependent only on a single table are called restriction predicates. These predicates are always applied before join conditions. The terms inner and outer table refererence to conceptual intermediate tables containing only those rows of their base table for which restriction predicates are true.
JOIN STEPS:
Each join step is described in the order of execution. Different messages are issued depending on the join method used.
Nested-Loop Join Method
The nested-loop join method searches the inner table for matching rows for each outer table row. A matching row is a row for which the join conditions are true.
Nested-loop is used when:
An example of when nested-loop has the lowest estimate cost:
NESTED-LOOP JOIN TBL n USING KEY xxxxx TO TBL n USING KEY xxxxx
Indicates table by its position in the FROM clause.
CA Datacom/DB five-character key name that has the lowest estimated cost. This may not be the key used at execution time.
Only the first join generates both lines. The outer table of subsequent joins is the intermediate result table of previous joins. This intermediate result table is not materialized, that is to say, it is not physically generated as a temporary table in the TTM area.
Index Merge Join Method
Index merge can only be used when:
An example of when index merge has the lowest cost:
Under these conditions index merge has the following advantages over nested-loop:
INDEX-MERGE JOIN TBL n USING KEY xxxxx TO TBL n USING KEY xxxxx
Table is identified by its position in the FROM clause.
CA Datacom/DB five-character key name of index used for the merge.
Sort-Merge Join Method
The sort-merge join method has the same restrictions as index-merge except that no matching indexes are required. Instead, the tables are sorted in the sequence the matching indexes would have provided before merging begins.
These sorts build temporary tables in the TTM area.
An example of when sort-merge is faster than nested-loop:
SORT TBL n FOR SORT-MERGE JOIN SORT TBL n FOR SORT-MERGE JOIN SORT-MERGE JOIN TBL n TO TBL m
Table is identified by its position in the FROM clause.
Sorts Required
The following messages indicate if a sort is eliminated by using an index:
KEY xxxxx USED FOR GROUPING KEY xxxxx USED FOR ORDERING
If a sort is required, its reasons are given in the following messages:
GROUP BY ........ SRT REASONS= xxxxxxx ORDER BY/DISTINCT SRT REASONS= xxxxxxx
The Compound Boolean Selection Facility cannot return rows in sort sequence because no index satisfies sort sequence.
ORDER BY refers to a SELECT list column that is an expression or function.
ORDER BY or GROUP BY refers to columns in multiple tables.
Index-merge join method is used. Its index does not satisfy ordering requirements.
DISTINCT specified.
UNION (without ALL) specified.
Predicates Evaluated in SQL-Subsystem
The following message indicates how many predicates are evaluated by the SQL subsystem:
***** nn PREDICATES EVALUATED BY SQL SUBSYSTEM IN JOIN STEP nn *****
These predicates cannot restrict index scan range, or be evaluated from the index; so, they cause data scanning.
If the data is remote, rows may be transferred to the requesting node only to be rejected by these predicates.
The following predicates are evaluated by the SQL subsystem:
You can dump the actual predicates by using the CA Datacom/DB Utility (DBUTLTY) request:
COMM OPTION=ALTER,TRACE=TRACECRS,JOBNAME=xxxxxxxx
If you cannot convert a predicate into a type that restricts index scan range or be evaluated from the index, you only improve efficiency slightly or make it worse by converting it to a predicate that the Compound Boolean Selection Facility (CBS) evaluates.
For example, converting the predicate:
"COL1 IN(&HOST1., &HOST2.)"
to
"COL1 = :HOST1 OR COL1 = :HOST2"
would not help much unless COL1 is in the scan index. Performance could be worse if there are many other predicates ANDed with this predicate that are evaluated by Compound Boolean Selection. This is because these other predicates are repeated for each IN list entry to be in the CBS-required disjunctive normal form.
|
Copyright © 2014 CA.
All rights reserved.
|
|