Creating the Plan Table
The EXPLAIN PLAN command uses a table to store information
about the execution plan chosen by the optimizer. If you examine the plan, you can see how the Oracle Server executes the statement. You must follow three steps to use EXPLAIN PLAN:
1. Create the plan output table.
2. Use the EXPLAIN PLAN command.
3. Retrieve the plan steps by using SQL statements against the plan table.
The PLAN_TABLE
You have several options in creating a plan table:
The default output table is named PLAN_TABLE.
You can use the utlxplan.sql script to create PLAN_TABLE.
In a Windows environment, this script can be found in ORACLE_HOME\rdbms\admin
under UNIX in $ORACLE_HOME/rdbms/admin.
In a client-server environment, be sure to use the correct (server side) version of this script.
You can create a similar table with any name you wish by using the CREATE TABLE .. AS SELECT command. You can also copy and edit the utlxplan.sql script; note that you should not change the structure of the table.
Create PLAN_TABLE Syntax:
The entire syntax for the PLAN TABLE is shown below:
Create table PLAN_TABLE (
statement_id varchar2(30),
timestamp date,
remarks varchar2(80),
operation varchar2(30),
options varchar2(30),
object_node varchar2(128),
object_owner varchar2(30),
object_name varchar2(30),
object_instance numeric,
object_type varchar2(30),
optimizer varchar2(255),
search_columns number,
id numeric,
parent_id numeric,
position numeric,
cost numeric,
cardinality numeric,
bytes numeric,
other_tag varchar2(255),
partition_start varchar2(255),
partition_stop varchar2(255),
partition_id numeric,
other long,
distribution varchar2(30)
);
Run a Standard script to create a Plan Table
SQL> @utlxplan.sql
Create your own Plan Table , with a different name
SQL> create table my_plan_table
2 as
3 select * from plan_table
4 where 1 = 2;
Friday, July 4, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment