文章目录
sql优化常见注意点
1、避免在where子句中使用 is null 或 is not null 对字段进行判断。
2、避免在 where 子句中使用 != 或 <> 操作符。
3、避免在 where 子句中使用 or来链接条件。
4、少用 in 或 not in。
5、注意 like 中通配符的使用。
6、避免在 where 子句中对字段进行表达式操作。
错误:select name from table where id/2 = 100
正确:select name from table where id = 100*2
7、避免在 where 子句中对字段进行函数操作。
8、在子查询中,用 exists 代替 in 是一个好的选择。