SQL 索引在什么情况下会失效

sql server数据库中索引失效的问题讨论  :

    1.索引字段进行判空查询时。也就是对索引字段判断是否为NULL时。如: select * from temp where time is null 此时就不检索time字段上的索引了

    2.对索引字段进行like查询时。如:select * from temp where des like '%王某某',后模糊'王某某%'不影响索引。

    3.判断索引列是否不等于某个值时。‘!=’操作符。如:select * from temp where amount != 0

    4.对索引列进行运算。这里运算包括+-*/等运算。也包括使用函数。比如:
    select * from temp where amount+count>10 此时索引不起作用。
    select * from temp where round(amount)>10 此时索引也不起作用。

posted @ 2014-11-07 16:28  Mark.Yang  阅读(3243)  评论(0)    收藏  举报