8月 24, 2014 |
Nix.Huang
LooseScan 策略
LooseScan 策略是semi join子查询的一种执行策略
比如:
select * from Country
where
Country.code in (select country_code from Satellite)
查找拥有卫星的国家(为了简化,不考虑多个国家共同拥有一个卫星),
假设Satellite. country_code有索引,那么我们可以按照国家编码的顺序获取卫星数据:如图:
LooseScan策略不是真的需要排序,它需要的是分组,在上面的图中,卫星以国家分组,比如澳大利亚拥有的卫星在一块,没有混合其他国家的卫星,这使得从一个组中选择一颗卫星更容易,你可以用其join 国家而不会重复:
explain select * from Country where Country.code in (select country_code from Satellite);
当然为