I'm studying about Explain plan and Execution plan
in Oracle and according to what I've read so far , The explained plan can differ from the actual plan used during statement execution. So I think execution plans are more useful for optimization purposes
in comparison with explain plans.
My question :
How do you usually generate execution plan for a Sql statement? After reading different articles I'm a bit confused now because in each of them a different approach is introduced ! For instance I came across this one :
explain plan
set statement_id = 'ex_plan1' for
select phone_number
from employee
where phone_number like '650%';
select PLAN_TABLE_OUTPUT
from table (DBMS_XPLAN.DISPLAY(STATEMENT_ID=>'ex_plan1'));
Is this the
correct way
for having the execution plan (not the explain plan)?What are other ways for having the correct execution plan?(The one
that optimizer
has chosen to execute the statement).
Thanks in advance