exists与in效率分析

Posted cengjianwei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 会用到索引

这篇(表扫描问题)

另外一篇(索引问题)

以上是关于exists与in效率分析的主要内容,如果未能解决你的问题,请参考以下文章