SQL中not in,not exists,和外连接效率比较
(1) select count(*) from t1 where object_id not in ( select object_id from t2);
(2) select count(*)
from t1
where not exists
(select null from t2 where t2.object_id = t1.object_id);
(3)select count(*)
from t1, t2
where t1.object_id = t2.object_id
and t2.object_id IS NULL;
问这三个语句效率比较,数据量在千万
(数据库为DB2或MS SQL2005)