-- 以A表为主表 -- 效率低,用到了A表上cc列的索引 select*from A where cc in (select cc from B) -- 效率高,用到了B表上cc列的索引 select*from A whereexists(select cc from B where cc=A.cc)
-- 以B表为主表 -- 效率高,用到了B表上cc列的索引 select*from B where cc in (select cc from A) -- 效率低,用到了A表上cc列的索引 select*from B whereexists(select cc from A where cc=B.cc)