MySQL-MySQL调优

2019-06-04  本文已影响0人  遇明不散

MySQL调优

选择合适的存储引擎
创建索引

在select、where、order by常涉及到的字段建立索引

SQL语句的优化
# 优化前
select number from t1 where number is null;
# 优化后
select number from t1 where number=0;
# 优化前
select id from t1 where id=10 or id=20 or id=30;
# 优化后
select id from t1 where id=10
union all
select id from t1 where id=20
union all
select id from t1 where id=30;
# 优化前
select id from t1 where id in(1,2,3,4);
# 优化后
select id from t1 where id between 1 and 4;
上一篇 下一篇

猜你喜欢

热点阅读