Blog Post

Troubleshooting Performance - Top CPU Queries

,

Today I came accross white paper "Troubleshooting Performance Problems in SQL Server" by Sunil Agarwal, Boris Baryshnikov, Tom Davidson, Keith Elmore, Denzil Ribeiro, Juergen Thomas 
in the MSDN site after reading through i thought i can mention couple of TSQL queries in the whitepaper for CPU issues which can be useful,
1. Top 50 Query contributing using most CPU,The query aggregates the CPU consumed by all statements with the same plan__handle
select top 50
    sum(qs.total_worker_time) as total_cpu_time,
    sum(qs.execution_count) as total_execution_count,
    count(*) as  number_of_statements,
    qs.plan_handle
from
    sys.dm_exec_query_stats qs
group by qs.plan_handle
order by sum(qs.total_worker_time) desc
2. TOP 25 stored procedures that have been recompiled,
select *
from sys.dm_exec_query_optimizer_info
select top 25
    sql_text.text,
    sql_handle,
    plan_generation_num,
    execution_count,
    dbid,
    objectid
from
    sys.dm_exec_query_stats a
    cross apply sys.dm_exec_sql_text(sql_handle) as sql_text
where
    plan_generation_num >1
order by plan_generation_num desc

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating