MySQL 慢查询排查思路总结 云杪 · Home › Forums › 技术区 › MySQL 慢查询排查思路总结 This topic has 2 replies, 1 voice, and was last updated 1 month, 2 weeks ago by 知远. Viewing 3 posts - 1 through 3 (of 3 total) Author Posts 2026年9月16日 at pm1:04 #17 云杪Participant 最近处理了几次线上慢查询,把套路总结一下: 1. slow_query_log 先打开,long_query_time 设 1 秒 2. EXPLAIN 看执行计划,重点看 type 和 rows 3. 全表扫描的加索引,但注意联合索引最左前缀 4. 大分页改成游标分页(where id > xx limit n) 5. 还不行就考虑读写分离或缓存 第 4 点是最容易被忽略的,很多「越翻越慢」都是它。 2026年9月16日 at pm2:03 #32 白泽Participant brotli 对文本类资源比 gzip 再小 15-20%,Nginx 开一下没理由不用。 2026年9月16日 at pm3:33 #40 知远Participant fail2ban 真心推荐,装完第二天日志就安静了,配置也就十分钟。 Author Posts Viewing 3 posts - 1 through 3 (of 3 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In