I have SQL Server 2008 with multiple databases on it. CPU get's up to 100% on that server quite a lot. I would like to figure out which database might be causing it. What is the easies way to do that?
My "magic" idal tool would show me:
- CPU, RAM and IO for SQL Server
- Drill down and show the same for each DB
- Drill down and show what queries causing issues, etc..
Best Answer
I prefer to use information from system view sys.dm_exec_query_stats. Activity monitor is inconvenient for me.
To get information from
sys.dm_exec_query_stats
I use following script which I found here (unfortunatly it is in Russian). Works for SQL Server 2005+.Using this script you can filter or group queries by the fields you want and, what is more important, get information about last execution time and object (SP, trigger) to which the query belong (Activity Monitor does not provide this information).
The only disadvantage of the script is that it returns aggregate performance statistics for cached query plans only. If a plan is removed from cache by any reason (shortage of memory, recompilation) you will not see statistics for that query.