Skip to Main Content
  • Questions
  • How to save and show real executions Plans without EE resources

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Jose Laurindo.

Asked: March 20, 2018 - 12:24 pm UTC

Last updated: March 21, 2018 - 10:37 am UTC

Version: 11.2.0.4 SE

Viewed 1000+ times

You Asked

Hi - I would like to know if it is possible to save (in a plan table, say) the real execution plan of a given SQL present in the SQL cache and later show it via DBMS_XPLAN - first please note, I´m talking about the real execution plan (and including the extentded stats such as A-ROWS and E-ROWs), not the estimatives from EXPLAIN PLAN : for EXPLAIN PLAN we know it is possible....
As far as I know, the only possibility here would be save the content of the related views (ie, V$SQL, V$SQL_PLAN, V$SQL_PLAN_STATISTICS_ALL) in my own custom tables and later write a query to assemble the plan.. NO other alternatives, maybe some built-in ?

Regards,

J. laurindo Chiappa

and Chris said...

You could use:

* DBMS_Xplan + gather_plan_statistics

set serveroutput off

select /*+ gather_plan_statistics */* 
from   t;

select * 
from   table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));


* Autotrace in SQL Developer

* SQL Trace + TKPROF

For more about these, read:

https://blogs.oracle.com/sql/how-to-create-an-execution-plan

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

What about the SAVE portion of the questiuon

J. Laurindo Chiappa, March 20, 2018 - 3:34 pm UTC

Yes, we can extract the execution plan via DBMS_XPLAN, right : but how we can to SAVE this execution plan in a table ?? And (of course) the database in point is STANDARD EDITION so we can´t get the execution plan from AWR, use SQL Monitoring, create a SQL baseline with the execution plan or things like that...
Chris Saxon
March 21, 2018 - 10:37 am UTC

Sorry, missed that.

You can run statspack with level >= 6. Note this only captures plans that are in the shared pool for queries exceeding one of the SQL thresholds.

Statspack can be an option...

J. Laurindo Chiappa, March 21, 2018 - 11:53 am UTC

Will try it : statspack iirc is deprecated so much probably it will not save all the extended plan statistics/details (such as A-ROWS/A-TIME/E-ROWS/E-TIME, OMem/1Mem/Used-Mem, etc), but I will try - if so, I will use a manual insert from v$sql/sql_plan/sql_plan_staqtistics_all and later will erite a query to assmeble the execution plan from that..

Regards,

Chiappa

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.