Skip to Main Content
  • Questions
  • Why Do We Have Commit/Rollback on Explain Plan

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Mohammed.

Asked: July 25, 2017 - 6:19 am UTC

Last updated: July 25, 2017 - 10:01 am UTC

Version: 11g

Viewed 1000+ times

You Asked

Hi Team,

I ran below query to see explain plan for my view. but after completion of query execution
when i was trying to disconnect , it is asking about

connection<conection_name> has uncommited.
1:- commit changes
2:- rollback changes
3;- abort connection disconnect

which one i need to select and why this is asking, i am doing only select

i am using sql developer
query:-

explain plan for select * from viewname

select plan_table_output
from table(dbms_xplan.display());


and Chris said...

When you create an explain plan, Oracle Database saves the information to its plan table:

set serveroutput off
explain plan for select * from dual;

select plan_table_output
from   table(dbms_xplan.display());

PLAN_TABLE_OUTPUT                                                           
Plan hash value: 4017058736                                                 
                                                                            
--------------------------------------------------------------------------  
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |  
--------------------------------------------------------------------------  
|   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |  
|   1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |  
--------------------------------------------------------------------------

select plan_id, operation, options, object_name from plan_table;

PLAN_ID  OPERATION         OPTIONS  OBJECT_NAME  
564      SELECT STATEMENT                        
564      TABLE ACCESS      FULL     DUAL  


These are the changes SQL Developer is asking if you want to commit/rollback.

Note that plan_table is a synonym to sys.plan_table$ (unless you've created your own...). This is a session-level temporary table (on commit preserve rows). So your data is wiped from this when you close the session regardless of whether you commit or rollback.

select owner, object_type
from   dba_objects
where  object_name = 'PLAN_TABLE';

OWNER   OBJECT_TYPE  
PUBLIC  SYNONYM

select table_name, temporary, duration
from   dba_tables
where  table_name = 'PLAN_TABLE$';

TABLE_NAME   TEMPORARY  DURATION     
PLAN_TABLE$  Y          SYS$SESSION 

Rating

  (1 rating)

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

Comments

Nice Explanation

Mohammed Tajmul, July 25, 2017 - 1:15 pm UTC

Nice Explanation. after this now i have confident about commit and rollback of explain plan.
Thanks Chris...Apriciate your Help...

More to Explore

Performance

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