日期:2014-05-16  浏览次数:20856 次

大家想想有什么方法优化下这个SQL?
SELECT A.ID
FROM A 
WHERE ID not in ( select ID from B );

想找出在A表有ID,而在B表没有ID的 所有ID号,每张表10W条数据的样子
每次运行内存就彪到1.5G(我2G内存)直接卡死,客户要求用Access
大家想想有什么方法

------解决方案--------------------
SQL code
select a.id
from a left join b on a.id=b.id
where b.id is null

------解决方案--------------------
select a.id from a left join b on a.id=b.id where b.id is null
在连接字段上建立过索引,ID