by shihang.mai
mysql用了Nested-Loop Join
驱动表R,连接表S
1. Simple Nested-Loop Join
Simple Nested-Loop Join表r的每行数据与s的全表做匹配,直到表r的数据全表扫描完,合并数据展示。
2. Index Nested-Loop Join
Index Nested-Loop Join表r的每行数据去s的索引找,匹配到再根据s的id找s的数据,直到表r的数据全表扫描完,合并数据展示。因为走索引,不用做全s表匹配,速度快
3. Block Nested-Loop Join
Block Nested-Loop Join表r将所有join用到的连接列和查询的相关列都放到join buffer中,然后join buffer整个去匹配s表,这样可以减少对s表的访问。
4. mysql选择join优先级
Index Nested-Loop Join >Block Nested-Loop Join > Simple Nested-Loop Join
网友评论