We have a Windows 2008 R2 Server with a SQL Server 2008 in it. That server has multiple .net sites that have SQL server databases on it.
We are currently experiencing an average CPU usage of 95%, and SQL Server is responsible for most of that usage.
I would like to identify which site is responsible for this so we can either optmize it or move it to another server. But I didnt find any direct way of looking this.
I’ve been looking if I could find:
- The database that is getting the most CPU intensive queries
- The process that is responsible for CPU intensive queries
One thing that also complicates the things is that we have multiple sites and “crons” using the same database. So once I identify the database I would also need to get some hints of which site/cron is responsible for it.
I would really appreciate any help on this as this issue is making our sites really slow…
Thanks
You can identify costly queries (and the databases they are associated with) using the DMVs, e.g. from this TechNet article:
These will tell you about heavy hitter queries, but unfortunately it won’t pinpoint a database that might have very high volume of small queries that are using small bits of CPU individually but large bits in aggregate. You can do that with this query from Glenn Allan Berry’s DMV queries:
Neither of these queries identifies the application that ran them, and the DMVs used don’t store that information (you would have to catch the queries in the act and note the application name in sys.dm_exec_sessions, or review a trace).
Of course you can automate this work with a variety of 3rd party performance tools on the market (disclaimer: I work for one of them, SQL Sentry, who produces Performance Advisor, which does all of the above, including keeping track of high-cost queries and maintaining the information about which database they ran in and what application called them).