mysql查询优化

select * from a where id in (select id from b)

等价于:

for select id from b

for select 8 from a where a.id = b.id

当b表数据必须小于a表数据时,in优于exists

select * from a where exists (select 1 from b where b.id = a.id)

等价于:

for select * from a 

for select * from b where b.id = a.id 

防止exists优于in

原文地址:https://www.cnblogs.com/saber-xi/p/13096018.html