How to fetch the SQL scipts with worst performance

来源:互联网 发布:javascript英文怎么读 编辑:程序博客网 时间:2024/05/19 21:43

Execute below SQL scipt to fetch the SQL scipts with worst performance

 

SELECT DB_NAME(dbid) AS [DB_NAME],creation_time,last_execution_time,total_physical_reads,total_logical_reads,total_logical_writes, execution_count , total_worker_time, total_elapsed_time, total_elapsed_time / execution_count 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_textFROM sys.dm_exec_query_stats AS qsCROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) stORDER BY total_elapsed_time / execution_count DESC


 

 

 

原创粉丝点击