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 会用到索引

这篇(表扫描问题)

另外一篇(索引问题)

posted @ 2019-04-22 15:03  vvull  阅读(131)  评论(0编辑  收藏  举报