|
Note 250646.1
Subject: Upgrading from 8.1.X to 9.X - Subquery Issues - Diagnosing and Resolving
Doc ID: Note:258945.1 Type: TROUBLESHOOTING
Last Revision Date: 13-JUL-2006 Status: PUBLISHED
PURPOSE
The Oracle Cost Based Optimizer is continually been enhanced. These enhancements were designed to improve performance but in some cases can cause a minority of queries to perform no better or worse than before. This article discusses some of the potential problems you may encounter when moving SQL Queries from Oracle 8i to Oracle 9i. It mainly centres on changes within the Cost Based Optimizer.
SCOPE & APPLICATION
DBAs and Application Designers
Upgrading from 8.1.X to 9.X - Subquery Issues - Diagnosing and Resolving
Subquery Unnesting Changes
Oracle 9i enabled subquery unnesting by default, controlled by the <Parameter:OPTIMIZER_FEATURES_ENABLE>.
If this was set to >= 9.0.0. then subquery unnesting would be enabled.
This means that on Oracle9i, queries containing subqueries are likely to be unnested when they were not in Oracle8i.
In most cases unnesting subqueries provides performance enhancements, but in some cases unnesting can produce a sub-optimal plan (or other factors, such as missing or innaccurate statistics, can produce a poor plan making the unnesting seem a bad option).
If an application has 8i to 9i upgrade related query tuning problem, please consider if subqueries are involved
Enhanced subquery unnesting
Diagnosing Subquery Unnesting issues:
Look for subqueries in the query text
Examine the explain plan and determine if the subquery has been unnested
Compare the current explain plan with the plan from the earlier version to see if the subquery is being handled differently
Disable subquery unnesting and see if that resolves the problem
To workaround subquery unnesting issues, you may disable unnesting in one of the following ways:
Set <Parameter:UNNEST_SUBQUERY> (underscore) = FALSE
alter session set "_UNNEST_SUBQUERY" = false;
If _unnest_subquery = false does not help then you may also need to set _always_semi_join = off (if the subquery is an IN or EXISTS) or _always_anti_join = off (if the subquery is a NOT IN or NOT EXISTS)
alter session set "_ALWAYS_SEMI_JOIN" = off;
alter session set "_ALWAYS_ANTI_JOIN" = off;
Set <Parameter:OPTIMIZER_FEATURES_ENABLE> to a value less than "9.0.0"
This is a static parameter and cannot be changed on the fly. It has to be set in one of the instance initialisation files (e.g. initSID.ora).
Set <Parameter:UNNEST_NOTEXISTS_SQ> (underscore) = OFF for not exists subqueries.
Use a /*+ NO_UNNEST */ hint in the subquery
Rewrite the query to modify or remove the subquery
Please note that the decision to unnest a subquery is not costed in Oracle9i. The decision to unnest a subquery is taken based on a set of heuristics (rules) before the query is optimized.
RELATED DOCUMENTS
Note 258167.1 Upgrading from 8.1.X to 9.X - Potential Query Tuning Related Issues
Note 144967.1 Manipulating the access path of queries involving subqueries
Note 199070.1 Optimizing statements that contain views or subqueries
@
@ INTERNAL Note 250646.1 SubQuery Unnesting - IN SubQuery
@ INTERNAL Note 258228.1 SubQuery Unnesting - NOT IN SubQuery
@ INTERNAL Note 258676.1 SubQuery Unnesting - EXISTS SubQuery . |
|