比较两个大型结果/行集的最有效方法的当前建议似乎是使用EXCEPT
运算符。随着行大小的增加(更改@last 值),下面这个自包含的 SQL 脚本变得非常低效。我试图在组合表中找到唯一的条目,但没有任何改进。
DECLARE @first AS INT, @step AS INT, @last AS INT;
-- This script is comparing two record sets using EXCEPT
-- I want to find additions from OLD to NEW
-- As number of rows increase performance gets terrible
-- I don't have to use two tables. I could use one combined table but I want the same result as quickly as possible
-- Compare 100 to 110 rows - 0 seconds
-- Compare …
Run Code Online (Sandbox Code Playgroud)