Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







Oracle SQL execution plan is incorrect

Oracle Database Tips by Donald BurlesonJuly 5, 2015

Question:  I've done a SQL trace using TKPROF and noticed that my real SQL execution plan does not match my explain plan display.  Why would the explain plan for a SQL query fail to give me the correct execution plan?

Answer:  It's proven that the standard relational "explain plan for" syntax can show a execution plan that is wrong, and you may not see the execution plan that is actually being used by the SQL optimizer. 
This "incorrect plan" issue commonly happens when your query has a bind variable.  This happens because the ancient explain plan utility does not consider the value of a host variable, while the Oracle optimizer may consider a host variable (when bind variable peeking is enabled with the 11g adaptive cursor sharing feature.
Remember, you should always use the dbms_xplan utility and avoid using the Oracle implementation of the ANSI standard "explain plan for querylist" syntax.

Wrong plans when not using "explain plan"

The CBO is extremely sophisticated proprietary software, and Oracle does not release details of its internal machinations. In general, the execution plan with match the actual execution and fetch, but sometimes the explain plan does not match the real-time execution plan, even when not using "explain plan for" syntax.  Some possible explanations may include:

  •  An "older" execution plan is cached in the library cache
  •  Dynamic sampling is altering the execution plan
  •  A bind variable influence runtime execution by using query rewrite (via setting cursor_sharing=force or cursor_sharing=similar), prior to the 11g adaptive cursor sharing enhancement.
  •  Your materialized view re-write has a bug

For complete details on advanced SQL tuning techniques, see my book "Oracle Tuning: The Definitive Reference". 

Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.