zoukankan      html  css  js  c++  java
  • SORT ORDER BY STOPKEY

    select * from 
    (
    select * from 
    (
    select  a.*,rownum rn
      from page a 
     where object_id >1000 and owner='SYS'
     order by object_id desc
    ) where rownum<=20
    ) where rn>=20;
    
    
    
    现在加个HINT
    
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  9w6p4hu1q1z4n, child number 0
    -------------------------------------
    select * from ( select * from ( select /*+ index(a) */ a.*,rownum rn   from page a  where object_id >1000 and owner='SYS'
    order by object_id desc ) where rownum<=20 ) where rn>=0
    
    Plan hash value: 3486388599
    
    ------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                        | Name       | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    ------------------------------------------------------------------------------------------------------------------------------------
    |*  1 |  VIEW                            |            |      1 |     20 |     20 |00:00:01.28 |     739 |       |       |          |
    |*  2 |   COUNT STOPKEY                  |            |      1 |        |     20 |00:00:01.28 |     739 |       |       |          |
    |   3 |    VIEW                          |            |      1 |  22595 |     20 |00:00:01.28 |     739 |       |       |          |
    |*  4 |     SORT ORDER BY STOPKEY        |            |      1 |  22595 |     20 |00:00:01.28 |     739 |  1234K|   574K| 1096K (0)|
    |   5 |      COUNT                       |            |      1 |        |  22130 |00:00:01.22 |     739 |       |       |          |
    |   6 |       TABLE ACCESS BY INDEX ROWID| PAGE       |      1 |  22595 |  22130 |00:00:01.22 |     739 |       |       |          |
    |*  7 |        INDEX RANGE SCAN          | IDX_PAGE_3 |      1 |  22595 |  22130 |00:00:01.20 |     150 |       |       |          |
    ------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("RN">=0)
       2 - filter(ROWNUM<=20)
       4 - filter(ROWNUM<=20)
       7 - access("OBJECT_ID">1000 AND "OWNER"='SYS' AND "OBJECT_ID" IS NOT NULL)
           filter("OWNER"='SYS')
    
    
    
    |*  4 |     SORT ORDER BY STOPKEY        |            |      1 |  22595 |     20 |
    
    
    
    SORT ORDER BY STOPKEY 是指:
    
    排序过后取数据 
    
    走索引后返回 100w条 
    
    是不是要对100w排序
    
    

  • 相关阅读:
    Element ui表单验证结束后再次打开清空验证信息
    oracle 新建用户 给用户设定权限
    oracle时间问题
    ORACLE 创建作业JOB例子
    ORACLE SQL PLUSE 创建作业 执行作业
    VS发布,签名出错 试图加载该页时出错,路径的形式不合法。
    Oracle 系统权限
    PL/SQL Developer 8.0 创建 Oracle Jobs 的疑惑
    信息系统系项目管理考试技巧
    水晶报表分组统计中如何让字段值居中显示
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13352406.html
Copyright © 2011-2022 走看看