码迷,mamicode.com
首页 > 其他好文 > 详细

索引反向使用案例,加index_desc hint

时间:2017-11-11 11:30:20      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:byte   rom   reads   ble   老师   Owner   disk   asc   access   

drop index idx_t;
create index idx_t on t(owner desc,object_type asc);


select /*+index(a,idx_t)*/ * from t a order by owner desc ,object_type asc;
执行计划
-------------------------------------------------------------------------------------
| Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |       | 74796 |    14M|  3463   (1)| 00:00:42 |
|   1 |  TABLE ACCESS BY INDEX ROWID| T     | 74796 |    14M|  3463   (1)| 00:00:42 |
|   2 |   INDEX FULL SCAN           | IDX_T | 74796 |       |   272   (1)| 00:00:04 |
-------------------------------------------------------------------------------------
统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
      12975  consistent gets
          0  physical reads
          0  redo size
    3400784  bytes sent via SQL*Net to client
      54052  bytes received via SQL*Net from client
       4878  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      73154  rows processed
      
      
select /*+index(a,idx_t)*/ * from t a order by owner asc ,object_type desc;
执行计划
----------------------------------------------------------------------------------------------
| Id  | Operation                    | Name  | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |       | 74796 |    14M|       |  6831   (1)| 00:01:22 |
|   1 |  SORT ORDER BY               |       | 74796 |    14M|    17M|  6831   (1)| 00:01:22 |
|   2 |   TABLE ACCESS BY INDEX ROWID| T     | 74796 |    14M|       |  3463   (1)| 00:00:42 |
|   3 |    INDEX FULL SCAN           | IDX_T | 74796 |       |       |   272   (1)| 00:00:04 |
----------------------------------------------------------------------------------------------
统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
       3459  consistent gets
          0  physical reads
          0  redo size
    3439096  bytes sent via SQL*Net to client
      54052  bytes received via SQL*Net from client
       4878  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
      73154  rows processed


      
select /*+index_desc(a,idx_t)*/ * from t a order by owner asc ,object_type desc;
执行计划
-------------------------------------------------------------------------------------
| Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |       | 74796 |    14M|  3463   (1)| 00:00:42 |
|   1 |  TABLE ACCESS BY INDEX ROWID| T     | 74796 |    14M|  3463   (1)| 00:00:42 |
|   2 |   INDEX FULL SCAN DESCENDING| IDX_T | 74796 |       |   272   (1)| 00:00:04 |
-------------------------------------------------------------------------------------
统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
      12968  consistent gets
          0  physical reads
          0  redo size
    3400803  bytes sent via SQL*Net to client
      54052  bytes received via SQL*Net from client
       4878  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      73154  rows processed


此处引用梁老师例子。
 
 

索引反向使用案例,加index_desc hint

标签:byte   rom   reads   ble   老师   Owner   disk   asc   access   

原文地址:http://www.cnblogs.com/Clark-cloud-database/p/7818271.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!