Skip to Main Content
Oracle SQL*Plus Pocket Reference
book

Oracle SQL*Plus Pocket Reference

by Jonathan Gennick
April 2000
Intermediate to advanced content levelIntermediate to advanced
94 pages
1h 52m
English
O'Reilly Media, Inc.
Content preview from Oracle SQL*Plus Pocket Reference

Tuning SQL

SQL*Plus can be employed as a tool to help tune SQL statements. You can use SQL’s EXPLAIN PLAN facility to get the execution plan for a statement into a table. Then you can query that table by using SQL*Plus to display that plan. If you don’t like the plan that Oracle is using, you can add optimizer hints to your SQL statement that specify how you want the statement to be executed.

Creating the Plan Table

Before you can use the EXPLAIN PLAN statement, you need to create a plan table to hold the results. Oracle provides a script named utlxplan.sql to create the plan table, and you’ll find it in the $ORACLE_HOME/rdbms/admin directory. Execute it as follows:

SQL> @e:\oracle\ora81\rdbms\admin\utlxplan

Table created.

The resulting table, PLAN_TABLE, looks like this:

Name                     Null?    Type
------------------------ -------- ----
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                   NUMBER(38)
OBJECT_TYPE                       VARCHAR2(30)
OPTIMIZER                         VARCHAR2(255)
SEARCH_COLUMNS                    NUMBER
ID                                NUMBER(38)
PARENT_ID                         NUMBER(38)
POSITION                          NUMBER(38)
COST                              NUMBER(38)
CARDINALITY                       NUMBER(38)
BYTES                             NUMBER(38)
OTHER_TAG                         VARCHAR2(255)
PARTITION_START                   VARCHAR2(255)
PARTITION_STOP                    VARCHAR2(255)
PARTITION_ID                      NUMBER(38)
OTHER                             LONG
DISTRIBUTION                      VARCHAR2(30)

The columns in the plan table often vary from one release of Oracle to the next. This version of the plan table is from Oracle8i release ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle SQL*Plus Pocket Reference, 3rd Edition

Oracle SQL*Plus Pocket Reference, 3rd Edition

Jonathan Gennick
Expert Oracle Exadata

Expert Oracle Exadata

Kerry Osborne, Randy Johnson, Tanel Pöder

Publisher Resources

ISBN: 1565929411Catalog PageErrata