mysql left join 效率优化问题

昊月星辰 昊月星辰 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
a,b,c三个表
a,b表1500+数据
c表6W数据

select a.id
from a
left join b on b.a_id=a.id
left join c on b.no = c.no

就这么简单的查询接近9S

1 SIMPLE a index id 4 1525 Using index
1 SIMPLE b index card_no 156 1617 Using where; Using index; Using join buffer (Block Nested Loop)
1 SIMPLE c index device_id 142 61007 Using where; Using index; Using join buffer (Block Nested Loop)

参考手册中MySQL如何优化LEFT JOIN和RIGHT JOIN——看了也没明白,还不是很懂

比如:在left join c on b.no = c.no and DATE_FORMAT(c.create_date, '%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d')
也没效果。

求明白人指点该如何提高查询速度,求告知如何设置 减少最内层(c表6W多次)的循环次数
...全文
评论 5
收藏 已收藏
分享
返回顶部
昊月星辰
MySQL 57,062 成员 56,759 内容