IBM Support

IT05891: SQL STATEMENT WITH MULTIPLE SIMILAR CORRELATED SUBEXPRESSIONS MIGHT RETURN INCORRECT RESULTS

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • An incorrect result set might be produced for a SQL statement
    that contains:
    
    - Multiple correlated subexpressions in the SELECT list that
    reference the same correlated sources
    - An ORDER BY clause
    
    and when the following optimizations are applied to that
    statement:
    
    - The similar correlated subexpressions are transformed into a
    common subexpression (CSE) during the query rewrite phase of
    optimization
    - The optimizer generates an access plan where a SORT operator
    is placed early in the access plan, before all the correlated
    CSE consumers are evaluated, to satisfy the ORDER BY clause.
    
    The following is an example of a SQL statement that satisfies
    the above conditions
    
    select z.e,
           (select 1 from t1 where a = 1 and b = (select distinct b
    from t2 where d=z.d)) as x,
           (select 1 from t1 where a = 2 and b = (select distinct c
    from t2 where d=z.d)) as y
      from (select * from t3 where a = 5) z, t4 where z.b=t4.b
    order by z.e
    
    Note that the presence of these conditions do not always lead to
    incorrect results. The two correlated subexpressions, x and y,
    must be transformed into a CSE and a SORT operation that is
    performed after the first reference to the CSE but before the
    second reference. You can confirm this pattern by capturing
    information about the access plan of the SQL statement using an
    EXPLAIN statement. Typically, the SORT operation will be
    performed before any CSE reference or after all the CSE
    references.
    

Local fix

  • You can attempt to avoid the SORT operator by creating an index
    to satisfy the ORDER BY clause. In the above example, a SORT
    operation can be avoided by creating an index on table T3 with
    column A as the leading key column in the index.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * All users                                                    *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to DB2 version 10.1.0.5.                             *
    ****************************************************************
    

Problem conclusion

  • The problem is first fixed in DB2 version 10.1.0.5.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IT05891

  • Reported component name

    DB2 FOR LUW

  • Reported component ID

    DB2FORLUW

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    YesHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-12-03

  • Closed date

    2015-06-16

  • Last modified date

    2015-07-10

  • APAR is sysrouted FROM one or more of the following:

    IT04173

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    DB2 FOR LUW

  • Fixed component ID

    DB2FORLUW

Applicable component levels

  • RA10 PSN

       UP

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"10.1","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
10 July 2015