有关排序的优化器统计信息

发布于 2024-11-06 19:47:40 字数 1572 浏览 2 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放低过去 2024-11-13 19:47:40

我想说的是,递归调用会进行一些排序 - 例如,当解析查询时,需要查询数据字典来检查表和列定义,其中一些查询将涉及 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文