SQLServer找出執行慢的SQL語句

2021-07-24 22:13:40 字數 1020 閱讀 7500

select

(total_elapsed_time / execution_count)/1000 n'平均時間ms'

,total_elapsed_time/1000 n'總花費時間ms'

,total_worker_time/1000 n'所用的cpu總時間ms'

,total_physical_reads n'物理讀取總次數'

,total_logical_reads/execution_count n'每次邏輯讀次數'

,total_logical_reads n'邏輯讀取總次數'

,total_logical_writes n'邏輯寫入總次數'

,execution_count n'執行次數'

,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) n'執行語句'

,creation_time n'語句編譯時間'

,last_execution_time n'上次執行時間'

from

where

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) not like '%fetch%'

order by

total_elapsed_time / execution_count desc;

轉至:

SQLServer找出執行慢的SQL語句

select total elapsed time execution count 1000 n 平均時間ms total elapsed time 1000 n 總花費時間ms total worker time 1000 n 所用的cpu總時間ms total physical reads n ...

找出執行效率低下的sql語句

select executions,disk reads,buffer gets,round buffer gets disk reads buffer gets,2 hit radio,round disk reads executions,2 reads per run,sql text fro...

sqlserver 找到執行慢的sql

select total elapsed time execution count 1000 n 平均時間ms total elapsed time 1000 n 總花費時間ms total worker time 1000 n 所用的cpu總時間ms total physical reads n ...