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