how to find querys which use max cpu time

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


dba
LVL 8
dba2dbaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:

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  
http://www.sql-server-performance.com/articles/per/bm_performance_dashboard_2005_p1.aspx 
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chapmandewCommented:
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
0
dba2dbaAuthor Commented:
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
0
chapmandewCommented:
works fine for me.  make sure your db compatabilty is set to 90 (its likely 80 right now)

0
dba2dbaAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.