我不知道为什么sys.pations查询运行得这么慢。它在表“sysrowsets”上花费了很多时间。真的很困惑。有人能帮忙回答这个问题吗?谢谢!
运行时间
问题1:2.7s
查询2:19s
查询详细信息
查询1:
SET STATISTICS IO ON;
GO
SELECT
sys_tables.name AS [TableId],
sysindexes.rowcnt AS [RowCnt]
FROM
sysindexes WITH (NOLOCK)
INNER JOIN sys.tables AS sys_tables WITH (NOLOCK)
ON sys_tables.object_id = sysindexes.id
INNER JOIN sys.schemas AS sys_schemas WITH (NOLOCK)
ON sys_schemas.schema_id = sys_tables.schema_id
WHERE
sys_schemas.name = 'xxxxxx' AND
LEN(sys_tables.name) = 26 AND
sysindexes.indid = 1
GO
SET STATISTICS IO OFF;
GO
信息:
(1001 row(s) affected)
Table 'syssingleobjrefs'. Scan count 3003, logical reads 9042, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'sysidxstats'. Scan count 2002, logical reads 6058, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'sysschobjs'. Scan count 1, logical reads 6835, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'sysclsobjs'. Scan count 0, logical reads 2, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
问题2:
SET STATISTICS IO ON;
GO
SELECT
sys_tables.name AS [TableId],
sys.partitions.rows AS [RowCnt]
FROM
sys.partitions WITH (NOLOCK)
INNER JOIN sys.tables AS sys_tables WITH (NOLOCK)
ON sys_tables.object_id = sys.partitions.object_id
INNER JOIN sys.schemas AS sys_schemas WITH (NOLOCK)
ON sys_schemas.schema_id = sys_tables.schema_id
WHERE
sys_schemas.name = 'xxxxxx' AND
LEN(sys_tables.name) = 26 AND
sys.partitions.index_id = 1
GO
SET STATISTICS IO OFF;
GO
信息:
(1001 row(s) affected)
Table 'syssingleobjrefs'. Scan count 3003, logical reads 9468, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'sysidxstats'. Scan count 1001, logical reads 4057, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'sysrowsets'. Scan count 1002, logical reads 644644, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'sysschobjs'. Scan count 1, logical reads 3832, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'sysclsobjs'. Scan count 0, logical reads 2, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
暂无答案!
目前还没有任何答案,快来回答吧!