使用索引的误区之二:使用了 和 != 操作符,导致查询不使用索引[6]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 lunar2000 的 blog

| id  | operation            |  name       | rows  | bytes | cost  |

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

|   0 | select statement     |             |       |       |       |

|*  1 |  table access full   | dept        |       |       |       |

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

predicate information (identified by operation id):

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

   1 - filter("dept"."dname"<>'developer')

note: rule based optimization

 

14 rows selected

 

将条件修改为“dname <'developer' and dname>'developer'”,则可以使用索引

select deptno from dept where dname <'developer' and dname>'developer';

 

plan_table_output

本文关键:使用索引的误区之二:使用了 和 != 操作符,导致查询不使用索引
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top