ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【索引】反向索引--条件 范围查询(二)

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

原创 Linux操作系统 作者:杨奇龙 时间:2010-09-07 17:58:48 0 删除 编辑
当 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 value: 711836071

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

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

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

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

|*  
1 |  INDEX FAST FULL SCAN| I_ID | 53518 |   261K|    29   (4)| 00:00:01 |

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

Predicate Information (identified by operation id):

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

   
1 - 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 value: 711836071

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

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

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

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

|*  
1 |  INDEX FAST FULL SCAN| I_ID | 53510 |   261K|    31  (10)| 00:00:01 |

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

Predicate Information (identified by operation id):

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

   
1 - 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;<>5 AND &quot;OBJECT_ID&quot;<>2 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 value: 3991740069

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

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

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

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

|   
1 |  INLIST ITERATOR  |      |       |       |            |          |

|*  
2 |   INDEX RANGE SCAN| I_ID |     2 |    10 |     3   (0)| 00:00:01 |

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

Predicate Information (identified by operation id):

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

   
2 - 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 value: 3991740069

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

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

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

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

|   
1 |  INLIST ITERATOR  |      |       |       |            |          |

|*  
2 |   INDEX RANGE SCAN| I_ID |     9 |    45 |     9   (0)| 00:00:01 |

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

Predicate Information (identified by operation id):

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

   
2 - access(&quot;OBJECT_ID&quot;=1 OR &quot;OBJECT_ID&quot;=2 OR &quot;OBJECT_ID&quot;=5 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)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22664653/viewspace-672908/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
MySQL DBA NoSQL DEVOPS

注册时间:2009-10-07

  • 博文量
    1026
  • 访问量
    8206128