mysql left join 优化

 

select * from a left join b on a.id=b.id  (a大表、b小表)

select * from b left join a on a.id=b.id  ---优化

大表 左关联 小表,很慢;小表 左关联 大表,很快。

 

select * from a join b on a.id=b.id -----自动选择小表作为驱动表

等于 select * from a left join b on a.id=b.id where b.id is null

参考

https://www.cnblogs.com/zedosu/p/6555981.html

https://blog.csdn.net/qq_36028348/article/details/88864691

posted @ 2019-03-28 11:06  诸葛子房  阅读(4230)  评论(0编辑  收藏  举报