top of page
DBAGenesis_png.png

Generate Execution Plan in Oracle

While working on SQL performance tuning, you must know what execution plan optimiser is generating. This execution plan defines how the SQL statement will be executed. There are multiple methods to generate an SQL plan. You can choose the best method that suits you.


AUTOTRACE – easy option


The autotrace option is used when you want to display the sql execution plan on your screen. The only problem with this option is that the sql query will execute first and then display the execution plan.


This might typically be a problem if a SQL statement is taking longer to execute. You need wait until the poor performing sql completes and then will be able to look at the execution plan.

set autotrace on;

select * from emp;


EXPLAIN PLAN


The explain plan method does not require query to execute first. It will display the optimiser execution plan without even executing the sql statement

explain plan for
select * from emp;

Run below to show the explain plan on the screen

SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());

Become a top notch dba with DBA Genesis
Become a DBA with DBA Genesis.png
bottom of page