Put your tips and tricks online - Share your knowledge! Login | Register
 
 
  Search     Advanced search
 

Home | Ask Question | Add tip | My tips | Recent tips & tricks | Suggest a category | FAQ | Forums

 
 
 
 Category : Home > Databases > Oracle > Performance Tuning     

Explain plan for an SQL query


1. Create the plan table

SQLPLUS> @${ORACLE_HOME}/rdbms/admin/utlxplan.sql

2. Delete old plan from the table and run explain plan. 
Replace 'select * from v$database' with the actuall sql statement you want explain plan for.

set lin 180
set pages 0
set feedback on
set echo off

delete from plan_table
where STATEMENT_ID = 'p1'
/

EXPLAIN PLAN SET STATEMENT_ID = 'p1' FOR 
select * from v$database
/

SELECT LPAD(' ',2*(LEVEL-1))||operation||' '||options
        ||' '||object_name
        ||' '||DECODE(id, 0, 'Cost = '||position) "Query Plan"
FROM plan_table
        START WITH id = 0 AND statement_id = 'p1'
        CONNECT BY PRIOR id = parent_id AND statement_id ='p1'
/


  Options
 
   del.icio.us  |  newsvine  |  digg  |  furl  |  google  |  yahoo  |  Ma.gnolia  |  vigillar  |  reddit  |  technorati  |  icerocket  |  pubsub

       Rate this tip:    

Start discussion or add comment to this tip

  Details
Tip reference : #26
views : 1115
Added on : 10/13/05
Submited by : h8dk97
 
Send a message Send a message Printer friendly output Printer friendly output
Display this member's tips Display this member's tips (159)
 
 
<< Previous Next >>
 Most viewed tips 
  Databases > Oracle > Security : How to unlock Oracle user account  
  Operating Systems > Unix : How to kill Unix user session  
  Databases > Oracle > Performance Tuning : How to enable trace in Oracle  
  Databases > Oracle : Kill user session  
   
  All categories
Databases | Programming | Hardware | Operating Systems | Networking | Internet | ERP / CRM | Games & Multimedia | Graphics & Design | Miscellaneous | Office Software | TipLib FAQ
 
 

Home |  FAQ |  Terms of Use |  Privacy Policy

© 2005 tiplib.com