exists与in效率分析

--A表大,B表小,效率高
select * from A where ID in (select ID from B)

--A表小,B表大,效率高
select * from A as TA where exists(select 1 from B as TB where TB.ID = TA.ID)

--not in 全表扫描
--not exists 会用到索引

这篇(表扫描问题)

另外一篇(索引问题)

原文地址:https://www.cnblogs.com/vvull/p/10750191.html