SQL Server 2008 - 即使工作实际上已完成,查询也需要很长时间才能完成
在 SSMS 中运行以下简单查询:
UPDATE tblEntityAddress SET strPostCode= REPLACE(strPostCode,' ','')
数据更新(至少在内存中)在一分钟内完成。我通过使用未提交的事务隔离级别执行另一个查询来验证这一点。但是,更新查询将继续运行另外 30 分钟。这里有什么问题呢?这是由于写入磁盘延迟造成的吗?
TIA
Running the following simple query in SSMS:
UPDATE tblEntityAddress
SET strPostCode= REPLACE(strPostCode,' ','')
The update to the data (at least in memory) is complete in under a minute. I verified this by performing another query with transaction isolation level read uncommitted. The update query, however, continues to run for another 30 minutes. What is the issue here? Is this caused by a delay to write to disk?
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最有可能的是,您的事务被影响
tblEntityAddress
的另一个事务锁定。运行
sp_lock
并查看tblEntityAddress
是否被另一个进程锁定。Most probably, you transaction is locked by another transaction which affected
tblEntityAddress
.Run
sp_lock
and see iftblEntityAddress
is locked by another process.在单独的 SSMS 窗口中,尝试运行以下命令:
只需替换为与 UPDATE 查询关联的 SPID(底部栏中登录名后面括号中的数字)。
连续运行上面几次并记下 wait_type 是什么。等待有多种类型 - 看看是什么(并让用户知道),它可以突出显示原因。
更新:
引自这篇 MS 知识库文章:
IO_COMPLETION
In a separate SSMS window, try running the following:
Just replaced with the SPID associated with your UPDATE query (number in brackets after your login name in the bottom bar).
Run the above a few times in succession and note what the wait_type is. There are numerous types of waits - see what that is (& let use know), it could highlight the cause.
Update:
Quotes from this MS KB article:
IO_COMPLETION
另一件需要考虑的事情是运行缓慢的触发器。
Another thing to consider is a slow running trigger.