【索引】反向索引--条件 范围查询(二)

简介:
当 where 条件中 含有 <> 条件或者 not in 时 走INDEX FAST FULL SCAN 执行计划中的 限制条件 not in 转换为 <>
PHP code:


SQL
select object_id from t1 where object_id <> 1;

53519 rows selected.



Execution Plan

----------------------------------------------------------

Plan hash value711836071

-----------------------------------------------------------------------------

Id  Operation            Name Rows  Bytes Cost (%CPU)| Time     |

-----------------------------------------------------------------------------

|   
SELECT STATEMENT     |      | 53518 |   261K|    29   (4)| 00:00:01 |

|*  
|  INDEX FAST FULL SCANI_ID 53518 |   261K|    29   (4)| 00:00:01 |

-----------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

   
filter(&quot;OBJECT_ID&quot;<>1)



Statistics

----------------------------------------------------------

          
1  recursive calls

        。。。。。。

      53519  rows processed



SQL
select object_id from t1 where object_id not in (45,65,95,32,1,2,5,64,83);

53511 rows selected.

Execution Plan

----------------------------------------------------------

Plan hash value711836071

-----------------------------------------------------------------------------

Id  Operation            Name Rows  Bytes Cost (%CPU)| Time     |

-----------------------------------------------------------------------------

|   
SELECT STATEMENT     |      | 53510 |   261K|    31  (10)| 00:00:01 |

|*  
|  INDEX FAST FULL SCANI_ID 53510 |   261K|    31  (10)| 00:00:01 |

-----------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

   
filter(&quot;OBJECT_ID&quot;<>45 AND &quot;OBJECT_ID&quot;<>65 AND &quot;OBJECT_ID&quot;<>95

              
AND &quot;OBJECT_ID&quot;<>32 AND &quot;OBJECT_ID&quot;<>64 AND &quot;OBJECT_ID&quot;<>83 AND

              &
quot;OBJECT_ID&quot;<>AND &quot;OBJECT_ID&quot;<>AND &quot;OBJECT_ID&quot;<>1)
where 条件中含有 = 号 或in 时   走INDEX RANGE SCAN 注意执行计划中的限制条件 in 被转换为 =
PHP code:


SQL
select object_id from t1 where object_id =55 or object_id =65;

Execution Plan

----------------------------------------------------------

Plan hash value3991740069

--------------------------------------------------------------------------

Id  Operation         Name Rows  Bytes Cost (%CPU)| Time     |

--------------------------------------------------------------------------

|   
SELECT STATEMENT  |      |     |    10 |     3   (0)| 00:00:01 |

|   
|  INLIST ITERATOR  |      |       |       |            |          |

|*  
|   INDEX RANGE SCANI_ID |     |    10 |     3   (0)| 00:00:01 |

--------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

   
access(&quot;OBJECT_ID&quot;=55 OR &quot;OBJECT_ID&quot;=65)

Statistics

----------------------------------------------------------

          
1  recursive calls

        。。。。。。

          2  row
PHP code:


SQL
select object_id from t1 where object_id in (45,65,95,32,1,2,5,64,83);

8 rows selected.



Execution Plan

----------------------------------------------------------

Plan hash value3991740069

--------------------------------------------------------------------------

Id  Operation         Name Rows  Bytes Cost (%CPU)| Time     |

--------------------------------------------------------------------------

|   
SELECT STATEMENT  |      |     |    45 |     9   (0)| 00:00:01 |

|   
|  INLIST ITERATOR  |      |       |       |            |          |

|*  
|   INDEX RANGE SCANI_ID |     |    45 |     9   (0)| 00:00:01 |

--------------------------------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

   
access(&quot;OBJECT_ID&quot;=OR &quot;OBJECT_ID&quot;=OR &quot;OBJECT_ID&quot;=OR

              &
quot;OBJECT_ID&quot;=32 OR &quot;OBJECT_ID&quot;=45 OR &quot;OBJECT_ID&quot;=64 OR &quot;OBJECT_ID&quot;=65 OR

              &
quot;OBJECT_ID&quot;=83 OR &quot;OBJECT_ID&quot;=95)
相关文章
|
PHP 索引
【索引】反向索引--条件 范围查询(二)
当 where 条件中 含有 条件或者 not in 时 走INDEX FAST FULL SCAN 执行计划中的 限制条件 not in 转换为 PHP code:SQL> select object_id from t1 where object_id  1;53519 rows selected.
662 0
|
SQL 索引
【索引】反向索引--条件 范围查询
---查看索引的类型SQL> col table_name for a10SQL> col index_name foa a10SQL> select table_name ,index_name ,index_type from user_indexes wh...
751 0
|
关系型数据库 MySQL 索引
mysql where过滤条件中and连接的两个条件的顺序不必和建立的联合索引的字段顺序一致
aa表 mysql> select * from aa; +------+--------+--------+ | id | name | other | +------+--------+--------+ | 1 | asdf | dfdfd | | ...
1100 0
|
SQL 索引 关系型数据库
【索引】反向索引引起排序
    反向索引是B*Tree索引的一个分支,它的设计是为了运用在某些特定的环境下的。Oracle推出它的主要目的就是为了降低在并行服务器(Oracle Parallel Server)环境下索引叶块的争用。
577 0
|
索引
【索引】反向索引
1,Creating dataReversed key indexes use b-tree structures, but preprocess key values before inserting them.
673 0
|
存储 索引
为什么范围后索引会失效 存储引擎不能使用索引中范围条件右边的列
比如说有三个字段 a b c,建立复合索引a_b_c。此时叶子节点的数据排序后可能为
129 0
|
8月前
|
SQL 关系型数据库 MySQL
MySQL数据库——索引(5)-索引使用(上),验证索引效率、最左前缀法则、范围查询、索引失效情况、SQL提示
MySQL数据库——索引(5)-索引使用(上),验证索引效率、最左前缀法则、范围查询、索引失效情况、SQL提示
129 0
|
关系型数据库 MySQL 开发者
索引分类和建索引命令语句|学习笔记
快速学习索引分类和建索引命令语句
110 0
|
SQL 算法 关系型数据库
Mysql使用left join连表查询时,因连接条件未加索引导致查询很慢
Mysql使用left join连表查询时,因连接条件未加索引导致查询很慢
198 0

热门文章

最新文章