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

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

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

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Understanding Oracle Explain Plan

Oracle Tips by Burleson Consulting

August 26, 2011

Question:  I need some tips for understanding the Oracle explain plan.  I have been told that reading the Oracle explain plan will help me identify tuning opportunities, but the explain plan and how to use it are a mystery to me.

Answer:  In the most basic terms, the Oracle explain plan is a tool that can be used to get Oracle to tell you how it plans on executing a query.  Clearly, this makes the explain plan a valuable tool for tuning.

Once the Oracle explain plan reveals how it plans on executing the query in question, the environment can be adjusted to run the query faster.

The Oracle explain plan is a statement that returns execution plans for the requested SELECT, UPDATE, INSERT and DELETE statements.  The execution plan for any given statement shows the operations in sequence used by Oracle to run that statement.

Information returned by the Oracle explain plan includes:

  • the tables referenced in the statement
  • the ordering and method with which each table is accessed
  • for join operations, the join method for the tables involved
  • data operations such as filter or sort included in the statement.

In addition to the information listed above, the Oracle explain plan table will also contain information on:

  • optimization
  • partitioning
  • parallel execution

The explain plan information is written to an explain plan table.  It is important to note that the explain plan table must be created before running the explain plan statement.

Once the Oracle explain plan table has been created, suspect SQL statements can be evaulated and tuned accordingly.

It is also possible to derive an Oracle explain plan using the SQL*Plus autotrace function as shown here:

SQL> SET AUTOTRACE ON
SQL> SELECT *
  2  FROM   emp e, dept d
  3  WHERE  e.deptno = d.deptno
  4  AND    e.ename  = 'SMITH';

The disadvantage of this method is that the statement has to complete its run in order to be evaluated.  If the statement is truly bad, this could involve a considerable amount of wasted time.

The preferred method would be the Oracle explain plan route.

The explain plan statement generates the execution plan for a query without executing the query itself, allowing the execution plan for poorly performing queries to be displayed without impacting the database. 

The following example shows how the explain plan statement is used to generate an execution plan:

SQL> EXPLAIN PLAN FOR  
2  SELECT *  
3  FROM   emp e, dept d  
4  WHERE  e.deptno = d.deptno  
5  AND    e.ename  = 'SMITH';

Explained.

If multiple people are accessing the same Oracle explain plan table, or a history of the Oracle execution plans is to be saved, the statement_id clause of the Oracle explain plan statement should be used.  This associates a user specified identifier with each explain plan, which can be used when retrieving the data. 

The following example shows how the statement_id is set using the Oracle explain plan statement.

SQL> EXPLAIN PLAN SET STATEMENT_ID = 'TIM' FOR  
2  SELECT *  
3  FROM   emp e, dept d  
4  WHERE  e.deptno = d.deptno  
5  AND    e.ename  = 'SMITH'; Explained.

The goals of tuning the SQL statements returned by the Oracle explain plan are fairly simple:

  • Eliminate sub-optimal large-table full-table scans: Ensure that the fastest access path to the data is chosen.  The execution plan "FULL" is the key.
  • Use fastest table join method: The optimizer must choose intelligently between nested loops joins, hash joins and star transformation join methods and these are displayed in the execution plan.  
  • Ensure optimal table-joining order: SQL will run fastest when the first table joins deliver the smallest result set.

With Oracle 11g, SQL Plan Management evolves more fully.

 
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.

 


 

 

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 -  2014

All rights reserved by Burleson

Oracle ? is the registered trademark of Oracle Corporation.


 

��  
 
 

 
 
 
 
oracle dba poster
 

 
 
Oracle performance tuning software 
 
Oracle Linux poster