1、避免在索引列上使用计算
where子句中,如果索引列是函数的一部分,优化器将不使用索引而使用全表扫描。例如:
(低效)select ... from [dept] where [sal]*12>25000;
(高效)select ... from [dept] where [sal]>25000/12;
2、不同类型的索引效能是不一样的,应尽可能先使用效能高的
数字类型的索引查找效率高于字符串类型,定长字符串char、nchar的索引效率高于变长字符串varchar、nvarchar的索引。
(低效)select ... from tableName where username='张三' and age>=21
(高效)select ... from tableName where age>=21 and username='张三'
参考文献:
1、http://www.cnblogs.com/sydeveloper/archive/2013/04/03/2992881.html