您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
一、描述
在查看执行计划测试的过程中遇到使用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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。