Advertisement
Pandaaaa906

U8慢查询

Mar 12th, 2024
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.02 KB | None | 0 0
  1. -- 在UTU.dbo中运行
  2.  
  3. SELECT
  4.     total_physical_reads  * 8 / 1024 "总物理读(Mb)",
  5.     total_logical_reads * 8 / 1024 "总逻辑读(Mb)",
  6.     total_logical_writes * 8 / 1024 "总逻辑写(Mb)",
  7.     total_worker_time /1000/1000 "总CPU耗时(s)",
  8.     creation_time 初次执行时间,
  9.     last_execution_time 上次执行时间,
  10.     execution_count 总运行次数,
  11.     execution_count / (DATEDIFF(day, creation_time, last_execution_time) + 1) 平均每天运行次数,
  12.     total_logical_writes / execution_count * 8 "平均逻辑写(Kb)",
  13.     total_elapsed_time /1000/1000 "总用时(s)",
  14.     total_elapsed_time / execution_count /1000/1000 "平均耗时(s)",
  15.     SUBSTRING (
  16.         st.text,
  17.         ( qs.statement_start_offset/ 2 ) + 1,
  18.     ( ( CASE statement_end_offset WHEN - 1 THEN DATALENGTH( st.text ) ELSE qs.statement_end_offset END - qs.statement_start_offset ) / 2 ) + 1
  19.     ) AS statement_text
  20. FROM
  21.     sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text ( qs.sql_handle ) st
  22. ORDER BY
  23. total_elapsed_time desc,
  24.     total_elapsed_time / execution_count DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement