Checkpoint--查看各DB上的脏页

 

可以使用sys.dm_os_buffer_descriptors来看数据页在buffer pool中的状态,其中is_modified来标示数据页是否为脏页

-----------------------------------------------------------------------------------------------------------------------

--查看各DB上的脏页

SELECT DB_NAME(database_id) AS DBName
,COUNT(1) AS DirtyPageCount 
FROM sys.dm_os_buffer_descriptors
WHERE is_modified=1
GROUP BY database_id

 

查看某个DB上脏页的分布情况

SELECT  OBJECT_NAME(p.[object_id]) AS [TableName] 
, ISNULL(i.name, ‘-- HEAP --‘) AS ObjectName 
, COUNT(1) AS PagesCount
FROM sys.allocation_units AS a 
INNER JOIN sys.dm_os_buffer_descriptors AS b 
ON a.allocation_unit_id = b.allocation_unit_id 
INNER JOIN sys.partitions AS p 
INNER JOIN sys.indexes i 
ON p.index_id = i.index_id 
AND p.[object_id] = i.[object_id] 
ON a.container_id = p.hobt_id 
WHERE b.database_id = DB_ID() 
AND B.is_modified=1
GROUP BY p.[object_id], i.name

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。