DB2 - Problembeschreibung
Problem IT05893 | Status: Geschlossen |
SQL STATEMENT WITH MULTIPLE SIMILAR CORRELATED SUBEXPRESSIONS MIGHT RETURN INCORRECT RESULTS | |
Produkt: | |
DB2 FOR LUW / DB2FORLUW / 970 - DB2 | |
Problembeschreibung: | |
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-Zusammenfassung: | |
**************************************************************** * USERS AFFECTED: * * All users * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to DB2 version 9.7.0.11. * **************************************************************** | |
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. | |
Lösung | |
The problem is first fixed in DB2 version 9.7.0.11. | |
Workaround | |
keiner bekannt / siehe Local-Fix | |
Weitere Daten | |
Datum - Problem gemeldet : Datum - Problem geschlossen : Datum - der letzten Änderung: | 03.12.2014 06.10.2015 06.10.2015 |
Problem behoben ab folgender Versionen (IBM BugInfos) | |
9.7.0.11 | |
Problem behoben lt. FixList in der Version | |
9.7.0.11 |