我是 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
最佳答案
我会说递归调用会进行一些排序 - 例如在解析查询时,需要查询数据字典来检查表和列定义,其中一些查询会涉及DISTINCT或其他需要排序的操作。
关于database - 关于排序的优化器统计信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5972353/