DB2 - Problem description
Problem IT02998 | Status: Closed |
DB2 MIGHT NOT OPTIMIZE SQL QUERIES CONTAINING OUTER JOINS AND EXISTENTIAL SUBQUERIES | |
product: | |
DB2 FOR LUW / DB2FORLUW / 970 - DB2 | |
Problem description: | |
DB2 might not be able to fully optimize queries containing the following pattern leading to long execution times. Pattern conditions: 1) The query contains one or more outer joins. 2) The null producing side of the outer join is involved in a correlated predicate inside a subquery 3) The subquery is of the form EXISTS or IN. 4) The subquery is used in the context of a predicate with no complex expressions like OR, CASE, etc. eg. select * from t1 left join t2 on t1.c1 = t2.c1 where exists (select * from t3 where t2.c2 = t3.c2); select * from t1 left join t2 on t1.c1 = t2.c1 where t2.c2 in (select c2 from t3); | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * All DB2 9.7 users * **************************************************************** * PROBLEM DESCRIPTION: * * See problem description above. * **************************************************************** * RECOMMENDATION: * * Upgrade to DB2 Version 9.7 Fix Pack 10 or higher. * **************************************************************** | |
Local Fix: | |
Rewrite the query to convert the subquery into a DISTINCT inner join: select * from t1 left join t2 on t1.c1 = t2.c1 inner join (select distinct c2 from t3) on t2.c2 = t3.c2 | |
Solution | |
First fixed in DB2 Version 9.7 Fix Pack 10. | |
Workaround | |
not known / see Local fix | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 07.07.2014 22.10.2014 22.10.2014 |
Problem solved at the following versions (IBM BugInfos) | |
9.7.FP10 | |
Problem solved according to the fixlist(s) of the following version(s) | |
9.7.0.10 |