Search

Wednesday, July 27, 2011

Memory usage per database

This very nice code gives the exact memory consumption ( current situation) per databse in an instance. One interesting thing is if we looks on server, the db that takes the most memoery is acutaly tempdb. When checking tempdb we se that that is extremely more used than the user databases. Makes sence to have tempdb on sql 2005 on dedicated disks and optiaze it as much as possible.

SELECT LEFT(CASE database_id
WHEN 32767 THEN 'ResourceDb'
ELSE db_name(database_id)
END, 20) AS Database_Name,
count(*)AS Buffered_Page_Count,
count(*) * 8192 / (1024 * 1024) as Buffer_Pool_MB
FROM sys.dm_os_buffer_descriptors
GROUP BY db_name(database_id) ,database_id
ORDER BY Buffered_Page_Count DESC

No comments:

Post a Comment