7 TraceCheck Generic
7 TraceCheck Generic
/*** RV ***/
/*** Performance Optimization & Troubleshooting ***/
/*********************************************************/
USE [master]
GO
-----------------------------------------------------------------------------------
-------
/* ANALYSIS */
SELECT
isnull(DatabaseName, '') as [DbName],
isnull(convert(varchar(max), [TextData]), '') as [Query],
avg(Reads) as [Avg_Reads],
max(Reads) as [Max_Reads],
avg(CPU) as [Avg_CPU],
max(CPU) as [Max_CPU],
avg(Duration/1000) as [Avg_Duration],
max(Duration/1000) as [Max_Duration],
count(*) as [Occurrence],
convert(bigint, avg(Reads) * count(*)) as [Total_Cost_Reads],
convert(bigint,avg(CPU) * count(*)) as [Total_Cost_CPU],
convert(bigint,avg(Duration/1000) * count(*)) as [Total_Cost_Duration]
FROM #tmp_Trace WITH (READUNCOMMITTED)
WHERE Reads is not null and Writes is not null and CPU is not null
-- and DatabaseName = 'DbName'
GROUP BY DatabaseName, convert(varchar(max), [TextData])
--HAVING count(RowNumber) >= 100
ORDER BY [Total_Cost_Reads] DESC
GO
----------
----------
----------