home clear 64x64
en blue 200x116 de orange 200x116 info letter User
suche 36x36
Neueste VersionenFixList
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Haben Sie Probleme? - Kontaktieren Sie uns.
Kostenlos registrieren anmeldung-x26
Kontaktformular kontakt-x26

DB2 - Problembeschreibung

Problem IC63994 Status: Geschlossen

THE DB2 SQL QUERY OPTIMIZER MAY CHOOSE A POOR PERFORMING SORT-MERGE
JOIN OPERATION UNDER CERTAIN CONDITIONS

Produkt:
DB2 FOR LUW / DB2FORLUW / 970 - DB2
Problembeschreibung:
In some cases, the DB2 SQL query optimizer (referred to 
optimizer herein) may choose to perform a sort-merge join on an 
effectively cartesian join which may not be an optimal decision 
in some cases.  For example, consider the following query: 
 
select * 
from T1, T2 
where T1.A=1 and T1.A=T2.A and T1.B=T2.B and T1.C=T2.C 
 
The two predicates "T1.A=1" and "T1.A=T2.A" imply a third 
predicate, "T2.A=1".  As a result, at the join operation, the 
join 
on T1.A=T2.A is effectively a cartesian product of two result 
sets that have all 1s in the join columns. 
 
The sort-merge join (MSJOIN) operation is limited to applying 
only one of the three join predicates.  This is clearly 
indicated in the details of the MSJOIN operator when viewing the 
explain of the query using the db2exfmt tool; e.g. 
 
    6) MSJOIN: (Merge Scan Join) 
 
        ... 
 
        Predicates: 
        ---------- 
        42) Predicate used in Join 
            Comparison Operator:         Equal (=) 
            Subquery Input Required:     No 
            Filter Factor:             1 
 
            Predicate Text: 
            -------------- 
            (Q1.A=Q2.A) 
 
        50) Residual Predicate 
            Comparison Operator:         Equal (=) 
            Subquery Input Required:     No 
            Filter Factor:             3.97033e-06 
 
            Predicate Text: 
            -------------- 
            (Q1.B=Q2.B) 
 
        51) Residual Predicate 
            Comparison Operator:         Equal (=) 
            Subquery Input Required:     No 
            Filter Factor:             0.5 
 
            Predicate Text: 
            -------------- 
            (Q1.C=Q2.C) 
 
Of the 3 predicates, 1 is classified as "Predicate used in Join" 
and the other two are "Residual". 
 
In some cases, the optimizer may choose to perform the MSJOIN 
using the effectively cartesian join predicate to perform the 
sort-merge join, applying the potentially filtering predicates 
as residuals.  In some cases, this may not be an optimal 
operation. 
 
This APAR will improve the optimizer's handling of these 
effectively cartesian join predicates.
Problem-Zusammenfassung:
**************************************************************** 
* USERS AFFECTED:                                              * 
* ALL                                                          * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* In some cases, the DB2 SQL query optimizer (referred to      * 
*                                                              * 
* optimizer herein) may choose to perform a sort-merge join on * 
* an                                                           * 
* effectively cartesian join which may not be an optimal       * 
* decision                                                     * 
* in some cases.  For example, consider the following query:   * 
*                                                              * 
* select *                                                     * 
* from T1, T2                                                  * 
* where T1.A=1 and T1.A=T2.A and T1.B=T2.B and T1.C=T2.C       * 
*                                                              * 
* The two predicates "T1.A=1" and "T1.A=T2.A" imply a third    * 
*                                                              * 
* predicate, "T2.A=1".  As a result, at the join operation,    * 
* the                                                          * 
* join                                                         * 
* on T1.A=T2.A is effectively a cartesian product of two       * 
* result                                                       * 
* sets that have all 1s in the join columns.                   * 
*                                                              * 
* The sort-merge join (MSJOIN) operation is limited to         * 
* applying                                                     * 
* only one of the three join predicates.  This is clearly      * 
*                                                              * 
* indicated in the details of the MSJOIN operator when viewing * 
* the explain of the query using the db2exfmt tool; e.g.       * 
*                                                              * 
*      6) MSJOIN: (Merge Scan Join)                            * 
*                                                              * 
*        ...                                                   * 
*                                                              * 
*      Predicates:                                             * 
*     ----------                                               * 
*    42) Predicate used in Join                                * 
*       Comparison Operator:    Equal (=)                      * 
*      Subquery Input Required:   No                           * 
*     Filter Factor:        1                                  * 
*                                                              * 
*   Predicate Text:                                            * 
*  --------------                                              * 
* (Q1.A=Q2.A)                                                  * 
*           50)                                                * 
* Residual Predicate                                           * 
* Comparison Operator:      Equal (=)                          * 
* Subquery Input Required:     No                              * 
* Filter Factor:     3.97033e-06                               * 
*                                                              * 
* Predicate Text:                                              * 
* --------------                                               * 
* (Q1.B=Q2.B)                                                  * 
*           51)                                                * 
* Residual Predicate                                           * 
* Comparison Operator:      Equal (=)                          * 
* Subquery Input Required:     No                              * 
* Filter Factor:     0.5                                       * 
*                                                              * 
* Predicate Text:                                              * 
* --------------                                               * 
* (Q1.C=Q2.C)                                                  * 
*                                                              * 
* Of the 3 predicates, 1 is classified as "Predicate used in   * 
* Join" and the                                                * 
* other two are "Residual".  In some cases, the optimizer may  * 
* choose to perform the MSJOIN                                 * 
* using the effectively cartesian join predicate to perform    * 
* the                                                          * 
* sort-merge join, applying the potentially filtering          * 
* predicates                                                   * 
* as residuals.  In some cases, this may not be an optimal     * 
*                                                              * 
* operation.                                                   * 
*                                                              * 
* This fix will improve the handling of these effectively      * 
* cartesian join predicates in the optimizer.                  * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Upgrade to Version 9.7 Fix Pack 1                            * 
****************************************************************
Local-Fix:
If you identify that the optimizer is choosing an effectively 
cartesian join as the MSJOIN join predicate (e.g by viewing the 
access plan using the visual explain or db2exfmt tool) and the 
performance of the query execution is poor, a survey of the 
cardinality estimates could indicate under estimation and 
therefore collecting appropriate statistics may provide the 
optimizer enough information to generate a better performing 
access plan. 
 
Another option, as a last resort, is to consider lowering the 
query optimization level to 0 for the affected query using the 
"current query optimization" special register, as follows: 
 
set current query optimization 0; 
<query> 
set current query optimization <dft_queryopt>; 
 
This will result in the optimizer using level 0 optimizations 
for the affected query only, avoiding the consideration of a 
MSJOIN operation altogether.
verfügbare FixPacks:
DB2 Version 9.7 Fix Pack 1 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 2 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 3 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 3a for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 4 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 5 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 7 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 9a for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 6 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 8 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 9 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 10 for Linux, UNIX, and Windows

Lösung
Problem was first fixed in Version 9.7 Fix Pack 1
Workaround
See LOCAL FIX
Weitere Daten
Datum - Problem gemeldet    :
Datum - Problem geschlossen :
Datum - der letzten Änderung:
22.10.2009
12.01.2010
12.01.2010
Problem behoben ab folgender Versionen (IBM BugInfos)
9.7.FP1
Problem behoben lt. FixList in der Version
9.7.0.1 FixList