DB2 - Problem description
| Problem IT04270 | Status: Closed |
DB2 OPTIMIZER MIGHT CHOOSE A NON-OPTIMAL ONE-FETCH GROUP BY | |
| product: | |
DB2 FOR LUW / DB2FORLUW / A10 - DB2 | |
| Problem description: | |
The optimizer might choose a one-fetch group by alternative,
requiring a less-optimal join order below the group by
operation, for a SQL statement that includes the following:
a. an aggregation function in the SELECT list with no grouping
columns, or grouping columns that are constant values
b. one or more joins in the query
c. the aggregation is on a single table, T
d. the only filtering on T is through one or more joins
e. the table T is well clustered on the join columns reference
in the filtering joins
The following example SQL statement satisfies the above
conditions since it includes a MAX aggregation function on T1,
which is filtered through the join with T2 only, and the
statement does not include and grouping columns:
SELECT MAX(T1.A)
FROM T1,T2
WHERE T1.B=T2.B AND T2.A=1
You can identify if a group by operation is a one-fetch by
collecting an EXPLAIN of the query and searching for the
ONEFETCH flag in the details of the group by operator:
ONEFETCH: (One Fetch flag)
TRUE
In most cases, a one-fetch group by provides optimal
performance, so its presence in the query execution plan is not
an indicator that you are hitting this issue. | |
| Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * ALL * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to DB2 version 10.1 Fix Pack 5 * **************************************************************** | |
| Local Fix: | |
You can use an optimization guideline to request a different query execution plan | |
| Solution | |
Fixed in DB2 version 10.1 Fix Pack 5 | |
| Workaround | |
See Local Fix | |
| Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 08.09.2014 13.07.2015 13.07.2015 |
| Problem solved at the following versions (IBM BugInfos) | |
| Problem solved according to the fixlist(s) of the following version(s) | |
| 10.1.0.5 |
|