Created
March 11, 2018 19:59
-
-
Save sqlpadwan/66ab11ea72d2493a8e579b0db16bde99 to your computer and use it in GitHub Desktop.
DMV to get information about how the buffer pool is.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
OBJECT_NAME ([p].[object_id]) AS [ObjectName], | |
[p].[index_id], | |
[i].[name], | |
[i].[type_desc], | |
[au].[type_desc], | |
[DirtyPageCount], | |
[CleanPageCount], | |
[DirtyPageCount] * 8 / 1024 AS [DirtyPageMB], | |
[CleanPageCount] * 8 / 1024 AS [CleanPageMB] | |
FROM | |
(SELECT | |
[allocation_unit_id], | |
SUM (CASE WHEN ([is_modified] = 1) | |
THEN 1 ELSE 0 END) AS [DirtyPageCount], | |
SUM (CASE WHEN ([is_modified] = 1) | |
THEN 0 ELSE 1 END) AS [CleanPageCount] | |
FROM sys.dm_os_buffer_descriptors | |
WHERE [database_id] = DB_ID (N'demo') | |
GROUP BY [allocation_unit_id]) AS [buffers] | |
INNER JOIN sys.allocation_units AS [au] | |
ON [au].[allocation_unit_id] = [buffers].[allocation_unit_id] | |
INNER JOIN sys.partitions AS [p] | |
ON [au].[container_id] = [p].[partition_id] | |
INNER JOIN sys.indexes AS [i] | |
ON [i].[index_id] = [p].[index_id] | |
AND [p].[object_id] = [i].[object_id] | |
WHERE [p].[object_id] > 100 | |
ORDER BY [ObjectName], [p].[index_id]; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment