您好,登錄后才能下訂單哦!
一、描述
在查看執行計劃測試的過程中遇到使用dbms_xplan.display無法查看執行計劃,發現是因為之前在測試的過程中打開了set autot on,關閉后(set autot off) ,執行計劃可以正常顯示。
二、操作過程
SQL>
SQL> explain plan for select count(*) from tt;
Explained.
Elapsed: 00:00:00.00
SQL> set lines 200 pages 2000
SQL> select * from table(dbms_xplan.display());
9 rows selected.
Elapsed: 00:00:00.02
Execution Plan
----------------------------------------------------------
Plan hash value: 2137789089
---------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 8168 | 16336 | 29 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR PICKLER FETCH| DISPLAY | 8168 | 16336 | 29 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
14 recursive calls
12 db block gets
55 consistent gets
0 physical reads
0 redo size
1124 bytes sent via SQL*Net to client
519 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
9 rows processed
##上面無法顯示執行計劃,很奇怪!!!
##關閉autot ,再次查看執行計劃OK!!!
SQL> set autot off
SQL> select * from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 3133740314
-------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 21556 (1)| 00:04:19 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| TT | 2762K| 21556 (1)| 00:04:19 |
-------------------------------------------------------------------
9 rows selected.
Elapsed: 00:00:00.02
##解釋一下執行計劃,首先是做了全表掃描這個很容易理解,sort aggregage 是因為做了count(*) 聚合。
SQL>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。