SQL优化

1、用join连接代替子查询,尽量避免使用子查询
2、只返回必要的列,用具体的字段名代替select * 语句
3、如果对group by语句的结果没有排序要求,要在语句后面加 order by null(group 默认会排序)
4、尽量使用where子句代替having子句(where是先过滤,having是后过滤)

 

 

参考文章

【1】https://blog.csdn.net/qq_35642036/article/details/82820129

【2】https://coolshell.cn/articles/1846.html

【3】https://tech.meituan.com/2014/06/30/mysql-index.html

【4】explain:Extra

posted @ 2023-11-23 09:59  先娶国王后取经  阅读(1)  评论(0编辑  收藏  举报