一、描述
在查看执行计划测试的过程中遇到使用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>原文链接:https://www.f2er.com/oracle/206147.html