Before to start to change everything, you must have a baseline that it established in normal load operation for comparisons.
1
2SELECT TOP 20
3 qs.sql_handle
4, DB_NAME(CAST(pa.value as INT)) as DatabaseName
5, qs.execution_count
6, qs.total_worker_time AS Total_CPU
7, total_CPU_inSeconds = qs.total_worker_time/1000000
8, average_CPU_inSeconds = (qs.total_worker_time/1000000) / qs.execution_count
9, qs.total_elapsed_time
10, total_elapsed_time_inSeconds = qs.total_elapsed_time/1000000
11, st.text , qp.query_plan
12FROM sys.dm_exec_query_stats AS qs
13CROSS APPLY sys.dm_exec_query_plan (qs.plan_handle) AS qp
14CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
15cross apply sys.dm_exec_plan_attributes(qs.plan_handle) pa
16where pa.attribute = 'dbid'
17ORDER BY qs.total_worker_time DESC
18go
You can use SQL Server Performance Dashboard Reports. https://sqldashboards.codeplex.com/
https://www.johnsansom.com/how-to-identify-the-most-costly-sql-server-queries-using-dmvs/
Comments