sql语句性能优化

来源:互联网 发布:怎么复制淘宝店铺宝贝 编辑:程序博客网 时间:2024/05/22 14:58

1、尽量不要使用模糊查询(会导致相关列的索引不可用);

2、有索引的列避免在sql语句中进行计算操作,尽量不使用not、<>、!=、is null、is not null,不进行数据类型转换、不使用函数、空值;

3、复杂的update和select语句适当拆分,多子句sql语句影响性能;

4、where子句中使用exist和not exist代替in和not in,having;

5、不要用字符格式来声明数字:where id = '100001';

6、不使用select * from ... select count(*) from... ;

7、尽可能少的使用耗费数据库引擎的distinct、union、minus、intersect、order by...