Execution plan denotes how Optimizer has decided to execute particular SQL.
The EXPLAIN PLAN
statement is a DML statement rather than a DDL statement. Therefore, Oracle Database does not implicitly commit the changes made by an EXPLAIN PLAN
statement.
About PLAN_TABLE
Oracle Database automatically creates a global temporary table PLAN_TABLE$
in the SYS
schema, and creates PLAN_TABLE
as a synonym.
Global temporary table PLAN_TABLE$
in the SYS
schema,
select owner,table_name,temporary,duration from dba_tables where table_name like 'PLAN_TABLE$';
OWNER TABLE_NAME TEMPORARY DURATION
-------------------- -------------------- ------------------------------ -----------------------------------------------
SYS PLAN_TABLE$ Y SYS$SESSION
PLAN_TABLE
as a synonym
SQL> select owner,object_name,object_type from dba_objects where object_name like 'PLAN_TABLE%';
OWNER OBJECT_NAME OBJECT_TYPE
-------------------- -------------------- ----------------------------------------
SYS PLAN_TABLE$ TABLE
PUBLIC PLAN_TABLE SYNONYM
All necessary privileges to PLAN_TABLE
are granted to PUBLIC
. Consequently, every session gets its own private copy of PLAN_TABLE
in its temporary tablespace.
SQL> select owner,privilege,grantee,table_name from dba_tab_privs where table_name like 'PLAN_TABLE%';
OWNER PRIVILEGE GRANTEE TABLE_NAME
---------- ---------- ---------- --------------------
SYS DELETE PUBLIC PLAN_TABLE$
SYS INSERT PUBLIC PLAN_TABLE$
SYS SELECT PUBLIC PLAN_TABLE$
SYS UPDATE PUBLIC PLAN_TABLE$
When we issue EXPLAIN PLAN statement it’s data populated in session’s PLAN_TABLE.
So to fetch data we can user DBMS_XPLAN.DISPLAY Function.
Required Privileges to CHECK VALUES FROM PLAN_TABLE using DBMS_XPLAN
GRANT SELECT ON v_$session TO user;
GRANT SELECT ON v_$sql_plan_statistics_all TO user;
GRANT SELECT ON v_$sql_plan TO user;
GRANT SELECT ON v_$sql TO user;
Basic Methods to Display Execution plan for EXPLAINED SQL .
After EXPLAINING SQL-ID we can use below mentioned methods to see execution plans.
1=> DBMS_XPLAN.DISPLAY()