how to find querys which use max cpu time

Posted on 2010-04-08
Medium Priority
Last Modified: 2012-06-21
my CPU utilization is going to 100% many times i want ot find out the querys which use high CPU time and try to modify them to increase performance

Can any body tell me the best way to do so

Question by:dba2dba
  • 2
  • 2
LVL 75

Accepted Solution

Aneesh Retnakaran earned 1000 total points
ID: 30124056

SELECT TOP 10 (total_worker_time * 1.0) / 1000000 AS CPU_Utilized_in_Seconds, text,*
FROM sys.dm_exec_query_stats
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
ORDER BY (total_worker_time * 1.0) / 1000000 DESC  
LVL 60

Expert Comment

ID: 30124547
Query stats will show the cached plans, but not trivial ones. For that you'll want to use profiler to capture when they're executed....Such as a select * from tablename

Author Comment

ID: 30210514
Msg 321, Level 15, State 1, Line 3
"sql_handle" is not a recognized table hints option. If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.
i get error

can i get query changed with out changing compatability
LVL 60

Expert Comment

ID: 30210881
works fine for me.  make sure your db compatabilty is set to 90 (its likely 80 right now)


Author Closing Comment

ID: 31712366

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question