Oracle's SQL-related performance tools let you examine the execution plan for a SQL statement, and thereby determine whether the statement can be better optimized. A statement's execution plan is the sequence of operations Oracle performs to run the statement. The row source tree is the core of the execution plan. It shows the following information:
An ordering of the tables referenced by the
statement
| An access method for each table mentioned in the statement | A join method for tables affected by join
operations in the statement
| Data operations like filter, sort, or aggregation | |
In addition to the row source tree, the plan table contains information about the following:
Optimization, such as the cost and cardinality of
each operation
| Partitioning, such as the set of accessed partitions | Parallel execution, such as the distribution
method of join inputs | |
Use the SQL script UTLXPLAN.SQL to
create a sample output table called PLAN_TABLE in your schema. The
exact name and location of this script depends on your operating system. For
example, it is located under ORACLE_HOME\rdbms\admin on Windows
systems. If you want an output table with a different name, you can rename it
with the RENAME SQL statement. AFTER THAT, you can get the
execution plan through the EXPLAIN PLAN SQL statement,
from querying V$SQL_PLAN, or from SQL trace.
To explain a SQL statement, you can enter the following:
EXPLAIN PLAN FOR <<SQL Statement>>
With multiple statements, you can specify a unique statement identifier and use that to identify your specific execution plan.
EXPLAIN PLAN
SET STATEMENT_ID = <<identifier>> FOR
<<SQL Statement>>
After you have explained the plan, you can use UTLXPLS.SQL
provided by Oracle to display the most recent plan table output.
You can also control the report by setting the AUTOTRACE
system variable. To use this feature, you must have the PLUSTRACE
role granted to you and a PLAN_TABLE table created in your schema.
The execution plan consists of four columns displayed in the following order:
For more details of the PLAN_TABLE columns, see Oracle reference.
Back to CS643 schedule