執行計劃函式display和display_cursor

lusklusklusk發表於2017-04-06
DISPLAY Function:Displays the contents of the plan table
display函式返回儲存在計劃表中的執行計劃,即SQL還未執行
資料來自PLAN_TABLE
PLAN_TABLE:PLAN_TABLE is automatically created as a global temporary table to hold the output of
an EXPLAIN PLAN statement for all users. PLAN_TABLE is the default sample output table
into which the EXPLAIN PLAN statement inserts rows describing execution plans

DBMS_XPLAN.DISPLAY(
table_name IN VARCHAR2 DEFAULT 'PLAN_TABLE',
statement_id IN VARCHAR2 DEFAULT NULL,
format IN VARCHAR2 DEFAULT 'TYPICAL',
filter_preds IN VARCHAR2 DEFAULT NULL);
statement_id指定sql語句的名字,它的預設值是null,如果使用了預設值,將顯示最近插入計劃表中的執行計劃
table_name指定計劃表的名字,預設值是plan_table,所以在執行的SQL語句之前加上explain plan for後,select * from plan_table=select * from table(dbms_xplan.display)




DISPLAY_CURSOR Function:Displays the execution plan of any cursor in the cursor cache
display_cursor函式返回儲存在庫快取中的執行計劃,即SQL已經執行過的
資料來自V$SQL_PLAN ,所以display_cursor不需要先執行explain plan for,因為它不是讀取計劃表
V$SQL_PLAN:contains the execution plan information for each child cursor loaded in the library cache.

DBMS_XPLAN.DISPLAY_CURSOR(
sql_id IN VARCHAR2 DEFAULT NULL,
cursor_child_no IN NUMBER DEFAULT 0,
format IN VARCHAR2 DEFAULT 'TYPICAL');
sql_id指被返回執行計劃的sql語句的序號,預設值是null,如果使用了預設值,當前會話的最後一條sql語句的執行計劃將被返回。

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

相關文章