简体   繁体   English

通过链接服务器查询非常慢

[英]Query through linked server is very slow

I have 2 SQL 2005 servers SRV1 and SRV2. 我有2个SQL 2005服务器SRV1和SRV2。 SRV2 is the linked server on SRV1. SRV2是SRV1上的链接服务器。 I run a storep proc with params on SRV2 and it is completed immediately. 我在SRV2上使用参数运行了一次storep proc,它立即完成。 But when I run the same proc through the linked server on SRV1, for example EXEC [SRV1].DB_TEST.dbo.p_sample_proc it takes about 8-10 minutes to complete. 但是,当我通过SRV1上的链接服务器运行同一proc时,例如EXEC [SRV1] .DB_TEST.dbo.p_sample_proc,大约需要8到10分钟才能完成。 After restarting SRV2 the problem is gone. 重新启动SRV2后,问题消失了。 But some time later it returns. 但是过了一段时间,它又回来了。 Does anyone have any ideas what it could be? 有谁知道这可能是什么?

Might need more rights on SRV2, says Linchi Shea in this article Linchi Shea在本文中说,可能需要SRV2的更多权利

The login used need to run DBCC SHOW_STATISTICS 使用的登录名需要运行DBCC SHOW_STATISTICS

Edit: After andomar's comment: what does this do? 编辑:在安多玛评论后:这是做什么的?

SELECT * FROM OPENQUERY ('SRV1', 'EXEC DB_TEST.dbo.p_sample_proc')

In SQL Server Management Studio, check Management -> Activity Monitor on SRV2. 在SQL Server Management Studio中,检查SRV2上的管理->活动监视器。 That should show you the state of the process that's running p_sample_proc. 那应该向您显示正在运行p_sample_proc的进程的状态。 Maybe it is blocking on a lock from some other process. 也许它阻止了其他进程的锁定。

It's safe to say that resetting a server removes all locks, and maybe the blocking application takes a while to reconnect to SRV2. 可以肯定地说,重置服务器会删除所有锁,并且阻止应用程序可能需要一段时间才能重新连接到SRV2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM