有关排序的优化器统计信息
我是 Oracle 11g 的新手,我有一个关于执行计划的问题。我运行了一个查询,即使查询中没有 ORDER BY 子句,执行计划的统计信息仍然显示内存中有 6 种排序。谁能向我解释为什么会发生这种情况?下面是查询和统计:
SQL> SELECT ZIP FROM NOZIPSORT WHERE ZIP BETWEEN '10000' AND '29999' AND rownum < 26;
25 rows selected.
Elapsed: 00:00:00.07
Execution Plan
----------------------------------------------------------
Plan hash value: 4176934817
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 25 | 150 | 2 (0)| 00:00:01 |
|* 1 | COUNT STOPKEY | | | | | |
|* 2 | TABLE ACCESS FULL| NOZIPSORT | 28 | 168 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM<26)
2 - filter("ZIP"<='29999' AND "ZIP">='10000')
Statistics
----------------------------------------------------------
311 recursive calls
0 db block gets
47 consistent gets
38 physical reads
520 redo size
805 bytes sent via SQL*Net to client
431 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
25 rows processed
I am a newbie in Oracle 11g and I have one question regarding the execution plan. I ran a query and even though there is no ORDER BY clause in the query, the statistics on the execution plan still shows that there are 6 sorts in memory. Can anyone please explain to me why this occurred? Below is the query and the statistics:
SQL> SELECT ZIP FROM NOZIPSORT WHERE ZIP BETWEEN '10000' AND '29999' AND rownum < 26;
25 rows selected.
Elapsed: 00:00:00.07
Execution Plan
----------------------------------------------------------
Plan hash value: 4176934817
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 25 | 150 | 2 (0)| 00:00:01 |
|* 1 | COUNT STOPKEY | | | | | |
|* 2 | TABLE ACCESS FULL| NOZIPSORT | 28 | 168 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM<26)
2 - filter("ZIP"<='29999' AND "ZIP">='10000')
Statistics
----------------------------------------------------------
311 recursive calls
0 db block gets
47 consistent gets
38 physical reads
520 redo size
805 bytes sent via SQL*Net to client
431 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
25 rows processed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想说的是,递归调用会进行一些排序 - 例如,当解析查询时,需要查询数据字典来检查表和列定义,其中一些查询将涉及 DISTINCT 或其他需要的操作排序。
I would say it will be the recursive calls that are doing some sorting - e.g. when the query is parsed, the data dictionary needs to be queried to check the table and column definitions, and some of these queries will involve DISTINCT or other operations that require sorting.