Error: cannot fetch last explain plan from PLAN_TABLE

wisdomone1發表於2013-03-26

/********構建測試表並插入記錄***************/
SQL> select a from t_sys;

         A
----------
         1
/*****可以顯示上述sql的執行計劃**********/
SQL> select * from table(dbms_xplan.display_cursor);--顯示cursor cache中的執行計劃,即shared pool

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------

SQL_ID  gg5wbsdrssnvm, child number 0
-------------------------------------
select a from t_sys

Plan hash value: 789675691

------------------------------------------------------------------------
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time
------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |       |       |       |     3 (100)|
|   1 |  TABLE ACCESS FULL| T_SYS |     1 |    13 |     3   (0)| 00:00:0

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------

------------------------------------------------------------------------

Note
-----
   - dynamic sampling used for this statement (level=2)


17 rows selected.

/******報錯*************/
SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------

Error: cannot fetch last explain plan from PLAN_TABLE


/****查閱官方手冊display函式顯示plan_table中的執行計劃,當然你也可以指定你的執行計劃表,但你的執行計劃表與要plan_table結構相同*****/
DISPLAY Function
 
This table function displays the contents of the plan table.
 
In addition, you can use this table function to display any plan (with or without statistics) stored
in a table as long as the columns of this table are named the same as columns of the plan table
(or V$SQL_PLAN_STATISTICS_ALL if statistics are included). You can apply a predicate on the
specified table to select rows of the plan to display.


SQL> explain plan for select * from t_oa;
 
Explained
 
SQL> select * from table(dbms_xplan.display);
 
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 3582308059
--------------------------------------------------------------------------------
| Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)| Time
--------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |          |     2 |    26 |     2   (0)| 00:00:01
|   1 |  PX COORDINATOR      |          |       |       |            |
|   2 |   PX SEND QC (RANDOM)| :TQ10000 |     2 |    26 |     2   (0)| 00:00:01
|   3 |    PX BLOCK ITERATOR |          |     2 |    26 |     2   (0)| 00:00:01
|   4 |     TABLE ACCESS FULL| T_OA     |     2 |    26 |     2   (0)| 00:00:01
--------------------------------------------------------------------------------
Note
-----
   - dynamic sampling used for this statement (level=2)
 
15 rows selected
 
SQL> select count(*) from plan_table;
 
  COUNT(*)
----------
         5
 
SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-757211/,如需轉載,請註明出處,否則將追究法律責任。

相關文章