当前位置:Gxlcms > 数据库问题 > SQL语句优化的理解

SQL语句优化的理解

时间:2021-07-01 10:21:17 帮助过:5人阅读

* from t where c - 1 = 1000;

正确:

select * from t where c = 1000 + 1;

3.应尽量避免在 where 子句中对字段进行 null 值判断:

select id from t where num=0

4.应尽量避免在 where 子句中使用 or 来连接条件:

select id from t where num=10 or num=20

可以这样查询:

select id from t where num=10

union all

select id from t where num=20

5.in 和 not in 也要慎用,否则会导致全表扫描

 参考:https://www.cnblogs.com/Little-Li/p/8031295.html

SQL语句优化的理解

标签:sql语句   磁盘   rom   list   nbsp   weight   color   刷新   sele   

人气教程排行