home clear 64x64
en blue 200x116 de orange 200x116 info letter User
suche 36x36
Latest versionsfixlist
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
Have problems? - contact us.
Register for free anmeldung-x26
Contact form kontakt-x26

DB2 - Problem description

Problem IT04173 Status: Closed

SQL STATEMENT WITH MULTIPLE SIMILAR CORRELATED SUBEXPRESSIONS MIGHT RETURN
INCORRECT RESULTS

product:
DB2 FOR LUW / DB2FORLUW / A50 - DB2
Problem 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.
Problem Summary:
**************************************************************** 
* USERS AFFECTED:                                              * 
* All users                                                    * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* See Error Description                                        * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Upgrade to DB2 version 10.5.0.5.                             * 
****************************************************************
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.
Solution
The problem is first fixed in DB2 version 10.5.0.5.
Workaround
not known / see Local fix
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
04.09.2014
19.12.2014
09.04.2015
Problem solved at the following versions (IBM BugInfos)
Problem solved according to the fixlist(s) of the following version(s)
10.5.0.5 FixList