假如只是想要ID的话,
select id from t01 where not exists (select 1 from t02 where t01.id=t02.id)
select id from t01 where id not in (select id from t02)
这样的句子最快。用到了两个表的INDEX.执行计划完全一样。
假如想要t01里面的所有的数据,
select * from t01 where not exists (select 1 from t02 where t01.id=t02.id)
select * from t01 where id not in (select id from t02)
用到了
1.t01 的 table access full
2.t02 index的index fast full scan
也就是说,执行计划也是一样的。