其他优化方向
- 使用多表連接查詢代替子查詢
- 使用union 代替or
- 對于分頁查詢--Mysql在進(jìn)行分頁查詢時越往后效率越低select * from student limit 1000000,10--1.在索引上完成排序分頁操作,最后根據(jù)主鍵關(guān)聯(lián)回原表查詢所需要的其他列內(nèi)容select a.* from student a, (select sid FROM student LIMIT 1000000, 10) b where a.sid = b.sid--2.先利用主鍵查找出分頁區(qū)間,然后在進(jìn)行分頁操作select * from student where sid > 1000000 limit 10
- 可以指定使用那個索引--建議select * from student use index(索引名)--忽略select * from student ignore index(索引名)--強(qiáng)制select * from student force index(索引名)
總結(jié)
- 上一篇: group by 语句优化
- 下一篇: 查看日志