--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 会用到索引
(表扫描问题)
(索引问题)
本文共 251 字,大约阅读时间需要 1 分钟。
--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/Cengjianwei/p/10750191.html