SQLSERVER 執行過的語句查詢

2021-10-09 02:21:08 字數 1475 閱讀 9420

select top 30000

total_worker_time/1000 as [總消耗cpu 時間(ms)],

execution_count [執行次數],

qs.total_worker_time/qs.execution_count/1000 as [平均消耗cpu 時間(ms)],

last_execution_time as [最後一次執行時間],

min_worker_time /1000 as [最小執行時間(ms)],

max_worker_time /1000 as [最大執行時間(ms)],

substring(qt.text,qs.statement_start_offset/2+1,

(case when qs.statement_end_offset = -1

then datalength(qt.text)

else qs.statement_end_offset end -qs.statement_start_offset)/2 + 1)

as [使用cpu的語法], qt.text [完整語法],

qt.dbid, dbname=db_name(qt.dbid),

qt.objectid,object_name(qt.objectid,qt.dbid) objectname

from sys.dm_exec_query_stats qs with(nolock)

where execution_count>1 and qs.creation_time between '2017-11-13 20:10:00' and '2017-11-13 20:15:00'

order by (qs.total_worker_time/qs.execution_count/1000) desc

select top 1000 

st.text as '執行的sql語句',

qs.execution_count as '執行次數',

qs.total_elapsed_time as '耗時',

qs.total_logical_reads as '邏輯讀取次數',

qs.total_logical_writes as '邏輯寫入次數',

qs.total_physical_reads as '物理讀取次數',

qs.creation_time as '執行時間' ,

qs.*

from sys.dm_exec_query_stats qs

sys.dm_exec_sql_text(qs.sql_handle) st

where qs.creation_time between '2015-08-01 00:00:00' and '2015-09-02 11:00:00'

order by

qs.total_elapsed_time desc

SQLSERVER 執行過的語句查詢

select top30000total worker time 1000as 總消耗cpu 時間 ms execution count 執行次數 qs.total worker time qs.execution count 1000as 平均消耗cpu 時間 ms last execution ...

SQLSERVER 執行過的語句查詢

select top30000 total worker time 1000as 總消耗cpu 時間 ms execution count 執行次數 qs.total worker time qs.execution count 1000as 平均消耗cpu 時間 ms last execution...

SQL Server 查詢執行過的sql語句與效能

select top1000 st.textas 執行的sql語句 qs.execution count as 執行次數 qs.total elapsed time as 耗時 qs.total logical reads as 邏輯讀取次數 qs.total logical writes as 邏...