sql优化之not in

sql : select ID from awhere XX <> 0 and ID not in (select ID from b)

4万多条记录,执行了316秒,无法接受。
 
优化为:
select a.ID from a where not exists (select b.ID from b where a.ID = b.ID) and a.XX <> 0
只需0.2秒。
原文地址:https://www.cnblogs.com/jhlong/p/5445440.html