Home > Ask the Oracle Experts > Questions & Answers > Interpreting tkprof/explain plan output
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Interpreting tkprof/explain plan output

Azim Fahmi EXPERT RESPONSE FROM: Azim Fahmi

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site
>
QUESTION POSED ON: 16 March 2004
I have a problem in SQL tuning. When I see the output of tkprof/explain plan, what values should I monitor (before and after tuning)?

>
EXPERT RESPONSE
This is a loaded question. There are training classes designed to go over how to interpret tkprof and explain plan. I strongly recommend you get hold of a tuning book and go over them.

Tkprof actually lets you analyze trace file that dumps all I/O information regarding a particular SQL statement. On the other hand, explain plan tells you how the Oracle cost-based optimizer is planning to run your query. The result of the explain plan will vary if the schema that you are using the SQL statement against is analyzed or not.

Therefore, please ensure that you analyze the schema using DBMS_STATS.GATHER_SCHEMA_STATS procedure.

You can run the following query against the plan table to see exactly what your query does. Please ensure you set your query for the plan table using the following command.

EXPLAIN PLAN SET STATEMENT_ID = 'ASIF_HALIYAL_QUERY_1'
FOR <YOUR SQL STATEMENT>

Now querying the plan table using the following SQL statement will let you know exactly what the CBO is planning to do with your SQL. Many things to look at for instance if the index you want the query to use is being used, is there a full table scan (note sometimes a full table scan may be desirable) and if so why, etc.

SELECT ID, PARENT_ID, cardinality "Rows",
LPAD(' ', 1*(LEVEL-1)) ||
LTRIM(' ', 1*(LEVEL-1)) ||
LTRIM(RTRIM(OPERATION)) || ' ' ||
LTRIM(RTRIM(OPTIONS)) || ' ' ||
LTRIM(RTRIM(OBJECT_NAME)) || ' ' ||
LTRIM(RTRIM(REMARKS))  EXECUTION_PLAN
FROM PLAN_TABLE
WHERE STATEMENT_ID = 'ASIF_HALIYAL_QUERY_1'
CONNECT BY PRIOR ID = PARENT_ID
AND PRIOR STATEMENT_ID = STATEMENT_ID
AND STATEMENT_ID = 'ASIF_HALIYAL_QUERY_1'
START WITH ID = 0 AND STATEMENT_ID = 'ASIF_HALIYAL_QUERY_1'
ORDER BY POSITION


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts