试图修复别人的代码。NOT IN 会破坏性能。我把它拿出来替换为不存在,我得到了不同的结果。注释掉的 not in 就在我的不存在之上。有人看到我在这里做的蠢事吗?
IF @ProcessComplete = 1
BEGIN
-- PRINT 'Group-Complete'
INSERT INTO @ProcessIDTable
SELECT DISTINCT(ProcessID)
FROM vPortalInbox
WHERE GroupUserIDs LIKE '%,' + CAST(@UserID AS VARCHAR(MAX)) + ',%'
AND StepOwnerID IS NULL
--AND ProcessID NOT IN (SELECT ProcessID FROM @ProcessIDTable)
And not exists (SELECT ProcessID FROM @ProcessIDTable)