我正在使用 SQL Server 2008 Management Studio 连接到 SQL Server 2000。
use [MyPrettyDb]
select top 19 * from information_schema.tables
它工作得很好,很甜蜜,而且很快。但这:
select top 20 * from information_schema.tables
超时停止。
超时的原因是什么?
附注select count(*) from information_schema.tables
返回很快;数据库中有334张表。
最佳答案
您可能被事务内运行的 DDL 语句阻止。运行 DBCC OPENTRAN
或 sp_lock
来确定哪个 session 负责此操作。
您可以通过运行以下脚本来重现此内容。
USE TEMPDB
GO
BEGIN TRAN
CREATE tABLE ttt(id int)
在另一个 session 中,运行
SELECT TOP 5 * FROM INFORMATION_SCHEMA.TABLES --will work
SELECT * FROM INFORMATION_SCHEMA.TABLES --will not work
关于t-sql - 针对 INFORMATION_SCHEMA 的查询超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11512591/