I am trying to create a report showing buffer cache used by each database on a server. I looked at creating a new metric but none of the categories made sense to me. Do I need to make a separate metric for each database on the server? This would be a pain to maintain as databases come and go.
Here is the basic query.
select db_name(database_id) as 'Database Name',
convert(numeric(8,2),count(page_id)/128.0) as Mb
from sys.dm_os_buffer_descriptors with (nolock)
where database_id !=32767
group by database_id
order by count(page_id) desc;