34,588
社区成员
发帖
与我相关
我的任务
分享
Select * from A where UserID not in (select UserID from B)
create index ix_a_userid_type on a(userId, type)
create index ix_b_userid_type on b(userId, type)
加两个索引再说吧。
此外, 你说表大, 具体有多大, 贴出来看看:
exec sp_spaceused 'a'
exec sp_spaceused 'b'
-- 试试这个
SELECT *
FROM TABLE_A AS A
LEFT JOIN TABLE_B B ON A.USERID= B.USERID AND A.TYPE=B.TYPE
WHERE B.USERID IS NULL