我有一个这样的sql更新语句
UPDATE t1 SET t1.Field = t2.Field
FROM Table1 as t1
INNER JOIN Table2 as t2 on t1.Key = t2.Key
WHERE t2.FilterField = 'abc'
where 子句使得没有行被更新,该语句运行 30 分钟。(该表有 5000 万行)
如果我将语句更改为有什么奇怪的
SELECT t1.Field, t2.Field
FROM Table1 as t1
INNER JOIN Table2 as t2 on t1.Key = t2.Key
WHERE t2.FilterField = 'abc'
几乎立即返回一个空的结果集
如果我将声明更改为
UPDATE t1 SET t1.Field = 1
FROM Table1 as t1
它会在大约 3 秒内更新表格。
我真的很困惑 SQL Server 在没有更新任何记录的更新语句上阻塞了什么。