snippetModerate
How do you get the explain plan?
Viewed 0 times
theyouplangethowexplain
Problem
Can some one please explain a bit about explain plan, and how does one get the explain plan for a query. Also, if there is any sql script which can be used as utility for this, that would be great.
Solution
You can use the package DBMS_XPLAN:
SQL> explain plan for select * from dual;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 2 |
| 1 | TABLE ACCESS FULL | DUAL | 1 | 2 | 2 |
--------------------------------------------------------------------
Note: cpu costing is offCode Snippets
SQL> explain plan for select * from dual;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 2 |
| 1 | TABLE ACCESS FULL | DUAL | 1 | 2 | 2 |
--------------------------------------------------------------------
Note: cpu costing is offContext
StackExchange Database Administrators Q#18639, answer score: 12
Revisions (0)
No revisions yet.