Index Skip Hint  在如下情况下使用:当在一个联合索引中,某些谓词条件不在联合索引的第一列时比如 id,object_name 在where条件中使用了object_name 时,可以通过使用Index Skip Hint 来访问数据。

SQL> create table t as select 1 id ,object_name from dba_objects;
表已创建。
SQL> insert into t select 2 id ,object_name from dba_objects;
已创建68301行。
SQL> insert into t select 3 id ,object_name from dba_objects;
已创建68301行。
SQL> insert into t select 4 id ,object_name from dba_objects;
已创建68301行。
SQL> commit;
提交完成。
SQL> create index t_idx on t(id,object_name);
索引已创建。
SQL> exec dbms_stats.gather_table_stats(user,'T',cascade => true);
PL/SQL 过程已成功完成。
SQL> set autot trace exp stat
SQL> select * from t where object_name='T';
执行计划
----------------------------------------------------------
Plan hash value: 3670166625    
--------------------------------------------------------------------------
| Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT |       |     7 |   189 |     6   (0)| 00:00:01 |
|*  1 |  INDEX SKIP SCAN | T_IDX |     7 |   189 |     6   (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("OBJECT_NAME"='T') 
       filter("OBJECT_NAME"='T')
统计信息
----------------------------------------------------------
        129  recursive calls  
          0  db block gets 
         37  consistent gets
          5  physical reads 
          0  redo size   
        531  bytes sent via SQL*Net to client
        416  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          4  sorts (memory)  
          0  sorts (disk) 
          4  rows processed

SQL> select /*+ full(t) */ * from t where object_name='T';
执行计划
----------------------------------------------------------                                     
Plan hash value: 1601196873   
-------------------------------------------------------------------------- 
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     7 |   189 |   337   (1)| 00:00:05 |
|*  1 |  TABLE ACCESS FULL| T    |     7 |   189 |   337   (1)| 00:00:05 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):    
---------------------------------------------------
   1 - filter("OBJECT_NAME"='T')  
统计信息
----------------------------------------------------------
          1  recursive calls
          0  db block gets 
       1232  consistent gets
        295  physical reads 
          0  redo size  
        531  bytes sent via SQL*Net to client
        416  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)    
          0  sorts (disk)  
          4  rows processed

SQL> select  * from t where object_name='T';
执行计划
----------------------------------------------------------  
Plan hash value: 3670166625      
--------------------------------------------------------------------------
| Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT |       |     7 |   189 |     6   (0)| 00:00:01 |
|*  1 |  INDEX SKIP SCAN | T_IDX |     7 |   189 |     6   (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------                                                                     
   1 - access("OBJECT_NAME"='T') 
       filter("OBJECT_NAME"='T')

统计信息
----------------------------------------------------------  
          1  recursive calls  
          0  db block gets 
         19  consistent gets 
          0  physical reads 
          0  redo size 
        531  bytes sent via SQL*Net to client  
        416  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client 
          0  sorts (memory) 
          0  sorts (disk)  
          4  rows processed
 
SQL> create table t2 as select object_id id,object_name from dba_objects;
表已创建。
SQL> create index idx_t2 on t2 (id,object_name);
索引已创建。
SQL> exec dbms_stats.gather_table_stats(user,'T2',cascade => true);
PL/SQL 过程已成功完成。
SQL> select * from t2 where object_name ='T';
执行计划
----------------------------------------------------------   
Plan hash value: 1513984157
-------------------------------------------------------------------------- 
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     | 
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     2 |    58 |    91   (2)| 00:00:02 |
|*  1 |  TABLE ACCESS FULL| T2   |     2 |    58 |    91   (2)| 00:00:02 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):   
---------------------------------------------------  
   1 - filter("OBJECT_NAME"='T')  
统计信息
----------------------------------------------------------  
        129  recursive calls         
          0  db block gets      
        348  consistent gets  
          0  physical reads 
          0  redo size     
        478  bytes sent via SQL*Net to client  
        416  bytes received via SQL*Net from client 
          2  SQL*Net roundtrips to/from client   
          4  sorts (memory)   
          0  sorts (disk)  
          1  rows processed  
 有以上两个执行计划可以看出t 表的id字段有4个不同的值,t2表上则有6万多个不同的值,对于前者,当谓词中没有联合索引的第一个字段是,cbo会选择index_ss。而对于第一个索引字段重复率很低的情况,选择index_ss 反而比fts 消耗跟多的资源。
SQL> select /*+ index_ss(t2 idx_t2) */ * from t2 where object_name='T';
执行计划
----------------------------------------------------------
Plan hash value: 2401255812   
---------------------------------------------------------------------------
| Id  | Operation        | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT |        |     2 |    58 | 68326   (1)| 00:13:40 |
|*  1 |  INDEX SKIP SCAN | IDX_T2 |     2 |    58 | 68326   (1)| 00:13:40 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):    
---------------------------------------------------
   1 - access("OBJECT_NAME"='T')  
       filter("OBJECT_NAME"='T')  
统计信息
----------------------------------------------------------  
          1  recursive calls   
          0  db block gets   
        387  consistent gets 
          0  physical reads  
          0  redo size     
        478  bytes sent via SQL*Net to client 
        416  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)    
          0  sorts (disk)   
          1  rows processed

【SQL 提示 之二】index_ss Index Skip Hint相关推荐

  1. Oracle 12c 新SQL提示(hint)

    Oracle 12c 新SQL提示(hint) Oracle 12c中引入了许多新特性,其中部分是和SQL相关的特性.而一些新的SQL提示也随着这些新特性被引入. enable_parallel_dm ...

  2. PostgreSQL Oracle 兼容性之 - INDEX SKIP SCAN (递归查询变态优化) 非驱动列索引扫描优化...

    标签 PostgreSQL , Oracle , index skip scan , 非驱动列条件 , 递归查询 , 子树 背景 对于输入条件在复合索引中为非驱动列的,如何高效的利用索引扫描? 在Or ...

  3. day12_oracle hint——SQL优化过程中常见Oracle中HINT的30个用法

    在SQL语句优化过程中,经常会用到hint, 以下是在SQL优化过程中常见Oracle中"HINT"的30个用法 1. /*+ALL_ROWS*/ 表明对语句块选择基于开销的优化方 ...

  4. 金仓数据库 KingbaseES SQL 语言参考手册 (11. SQL语句:ABORT 到 ALTER INDEX)

    11. SQL语句:ABORT 到 ALTER INDEX 本章描述各种类型的SQL语句,由于类型较多,将按字母顺序排列分组.这是第一组SQL语句. 包含以下章节: SQL语句类型 SQL语句各章节是 ...

  5. ASP.NET Web——GridView完整增删改查示例(全篇幅包含sql脚本)大二结业考试必备技能

    ASP.NET Web--GridView 完整增删改查示例(全篇幅包含sql脚本)大二结业考试必备技能 环境说明 系统要求:win7/10/11 开发语言:C# 开发工具:Visual Studio ...

  6. oracle index skip scan,索引跳跃式扫描(INDEX SKIP SCAN)

    索引跳跃式扫描(INDEX SKIP SCAN) 索引跳跃式扫描(INDEX SKIP SCAN)适用于所有类型的复合B树索引(包括唯一性索引和非唯一性索引),它使那些在where条件中没有对目标索引 ...

  7. 【PTE】SQL注入(二)

    七.盲注 盲注会用到上百条语句去一个字母一个字母猜,所以一般都会用自动化工具去跑,而不是手工注入 (一)布尔盲注(bool) 特点:无论参数是什么,只有两种:①正常显示,②啥也不显示 1.几个函数 s ...

  8. SQL开发技巧(二) 【转】感觉他写的很好

    本文转自: http://www.cnblogs.com/marvin/p/DevelopSQLSkill_2.html 本系列文章旨在收集在开发过程中遇到的一些常用的SQL语句,然后整理归档,本系列 ...

  9. gulp4.0的坑:提示: Error: watching index.html: watch task has to be a function (optionally generated by u

    提示: Error: watching index.html: watch task has to be a function (optionally generated by using gulp. ...

最新文章

  1. 安卓设置菊花动画_Android Progressbar自定义菊花效果
  2. UA MATH567 高维统计II 随机向量10 Grothendieck不等式的证明 版本二:kernel trick
  3. 格式说明_现代诗歌的写作格式是什么,能否举例说明?
  4. 迁移学习领域自适应:具有类间差异的联合概率最大平均差异
  5. boost::serialization模块实现快速二进制归档的测试程序
  6. Django从理论到实战(part44)--JsonResponse类
  7. 十年探索,云上明灯,re:Invent再启掀产业风暴
  8. A - 敌兵布阵 (HDU - 1166)
  9. phpMyAdmin批量修改Mysql数据表前缀的方法
  10. mysql孤立锁_SQL Server解决孤立用户浅析
  11. PHP的HashTable实现
  12. 普通人学python有意义吗-普通人为什么要学习Python?
  13. Android 对话框用法
  14. 如何在js中直接使用id_node.js中的npm update如何使用
  15. Android之xUtils-3.0数据库框架详解
  16. 图像处理之直方图匹配
  17. python实验总结与分析_Python实验报告二
  18. python之Django框架将sqliteman数据库数据显示在页面上
  19. 星星之火-47: 5G的八大组网方案
  20. [交互设计]简约至上4原则

热门文章

  1. chrome 您即将提交的信息不安全_各地市场监督管理局发布食品安全抽检信息 通报不合格样品批次...
  2. css盒模型只能应用于html,iframe,css样式表,盒模型的使用方法-2019年9月3日
  3. python切片长度_python的间隔切片技巧
  4. 可编程led灯带原理_技术分享:二极管发光原理与LED灯带
  5. 多个异步之间的协作方案
  6. WXS是小程序的一套脚本语言
  7. 有问题,上微信问答群!
  8. mysql 免安装 自启动_MYSQL在Win下免安装zip
  9. java怎么从数据库中查询_java – 从数据库中检索的实体与查询中的情况相同
  10. Linux 编辑doc,Linux命令大全(文档编辑).doc