The AUTOTRACE Command in SQLPlus can be used to generate EXPLAIN PLANS and Run Time Statistics. The EXPLAIN PLAN is generated after the SQL Statement is executed.
Explain Plan (Optimization): To analyze for tuning the SQL statement Explain Plan is used. For that run the UTLXPLAN.SQL script to create table named PLAN_TABLE, for receiving the output of an Explain Plan statement.
Eg. Explain Plan
Set Statement_id 'My Customer'
Into Plan_table
For Select lastname, firstname
From customers
Where state = 'NY'
Output: Select statement_id,operation,options,cost from plan_table;
Statement_id Operation Options Cost
My Customer Select Statement 9
My Customer Table Access Full Access 16
The Explain Plan command of oracle7 uses the current statistics in the data dictionary to do its best to return an accurate execution plan and corresponding cost to executing a statement. However, if statistics are not up-to-date then of course the Explain Plan command might not return an accurate execution plan and cost.
No comments:
Post a Comment