统计分析SQL Server Profiler 跟踪的SQL

时间:2014-04-30 22:37:39   收藏:0   阅读:327
--跟踪文件读入到表中分析
SELECT * INTO ZGSJY
FROM fn_trace_gettable(‘E:\wxxcdbprofiler.trc‘, default);
--某时间内,最耗时SQL
select TOP 100 SUBSTRING(Textdata,1,660) as ‘名称‘,
count(*) as ‘数量‘, sum(duration/1000) as ‘总执行时间ms‘,
       avg(duration/1000) as ‘平均执行时间ms‘,
       avg(cpu) as ‘平均CPU时间ms‘,
       avg(reads) as ‘平均读次数‘,
       avg(writes) as ‘平均写次数‘
from ZGSJY group by substring(Textdata,1,660) 
order by sum(duration) desc
通过SQL Server Profiler 跟踪程序或者数据库运行过程中SQL的执行信息。然后分析sql耗时,从而明确优化点。
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!