In the likely event that you might need to get the total buffer pool memory used by all databases at SQL instance level, this script is for it.
SELECT cast( cast( COUNT(*) /128.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' AS TotalUsageBufferPool FROM sys.dm_os_buffer_descriptors
SELECT CASE database_id WHEN 32767 THEN 'ResourceDb' ELSE db_name(database_id) END AS DatabaseName, cast( COUNT(*) /128.0 as decimal(10,2)) AS [BufferPool(MB)] FROM sys.dm_os_buffer_descriptors GROUP BY DB_NAME(database_id) ,database_id ORDER BY [BufferPool(MB)] DESC
-- SQL2012/2014/2016/2017 select cast(cast(physical_memory_kb /1024.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' TotalPhysicalRAM, cast(cast(visible_target_kb /1024.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' MaxRAM, -- max memory configure at sql server level cast(cast(committed_target_kb /1024.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' ReservedRAM, --memory reserved cast(cast(committed_kb /1024.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' UsedRAM --memory used currently FROM sys.dm_os_sys_info -- for SQL2005/2008/2008R2 SELECT cast(cast(physical_memory_in_bytes /1024.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' TotalPhysicalRAM, cast(cast(bpool_visible /128.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' MaxRAM, -- max memory configure at sql server level cast(cast(bpool_commit_target /128.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' ReservedRAM, --memory reserved cast(cast(bpool_committed /128.0/1024.0 as decimal(10,2)) as varchar(10)) + 'GB' UsedRAM --memory used currently FROM sys.dm_os_sys_info
That is all for now. I hope you find these scripts helpful. Let me know any remarks you may have.
No comments:
Post a Comment
Let me know any remarks or questions you may have. Please write down your name.