• 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排序
    
    

  • 相关阅读:
    一些关于"虚拟交易"的有趣文章
    Windows中的消息队列:Message Queuing (MSMQ)
    ATLStyle模板 不用虚函数实现多态
    AIX 下获取系统CPU及内存的使用情况方法
    关于HPUNIX C 兼容性
    Android进阶Acticivity的启动模式
    ViewState & UpdatePanle & ReadOnly属性
    由网站构架演变说起
    '操作必须使用一个可更新的查询'解决方法
    ScriptManager & ClientScriptManager
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13352406.html
Copyright © 2020-2023  润新知