In some cases, we may need to determine the memory rates used by databases. Because some databases using extra memory may be degrading the performance of other databases. For example, a user who wants to generate reports can reduce the performance of critical production database. In this case, we can restrict the user who wants to generate reports with Resource Governor. For more information about resource manager, please read the following article.
“How To Restrict a User’s Resource Usage Using Resource Governor”
When you run the following T-SQL, it will list the database-based Memory usage rates.
SELECT DB_NAME(database_id) AS [Database Name],
COUNT(*) * 8/1024.0 AS [Cached Size (MB)]
WHERE database_id > 4
GROUP BY DB_NAME(database_id)
ORDER BY [Cached Size (MB)] DESC