码迷,mamicode.com
首页 > 数据库 > 详细

SQL Server 监测语句

时间:2018-06-16 19:35:14      阅读:357      评论:0      收藏:0      [点我收藏+]

标签:col   else   bsp   font   占用   db_name   state   length   string   

 

select top 20 
qs.creation_time,
last_execution_time, total_physical_reads, total_logical_reads, total_logical_writes,
DB_NAME(dbid) dbname, execution_count, --total_worker_time, last_worker_time, --substring(convert(char(23),DATEADD(ms,total_worker_time/1000,0),121),12,23) total_worker_time, --total_elapsed_time, last_elapsed_time, substring(convert(char(23),DATEADD(ms,total_elapsed_time/1000,0),121),12,23) total_elapsed_time, --total_elapsed_time / execution_count avg_elapsed_time, substring(convert(char(23),DATEADD(ms,(total_elapsed_time / execution_count)/1000,0),121),12,23) avg_elapsed_time, SUBSTRING(st.text, (qs.statement_start_offset/2) + 1, ((CASE statement_end_offset WHEN -1 THEN DATALENGTH(st.text) ELSE qs.statement_end_offset END - qs.statement_start_offset)/2) + 1) AS statement_text FROM sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st --ORDER BY execution_count desc 计划执行总次数 --ORDER BY total_elapsed_time --计划执行总时长 order by last_worker_time desc;--最近一次执行cpu 占用时长

SQL Server 监测语句

标签:col   else   bsp   font   占用   db_name   state   length   string   

原文地址:https://www.cnblogs.com/wangwust/p/9191135.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!