SELECT 
       SUBSTRING(dest.TEXT,
                 (deqs.statement_start_offset/2)+1,(
CASE deqs.statement_end_offset WHEN
-1 THEN
                        DATALENGTH(dest.TEXT)
                  ELSE
deqs.statement_end_offset
                  END
- deqs.statement_start_offset)/2) + 1)
AS
statement_text, 
deqs.last_execution_time
,deqs.execution_count,deqs.last_worker_time
as [Last CPU time],
deqs.last_physical_reads
, deqs.last_logical_reads,deqs.last_logical_writes,
deqs.last_elapsed_time
   FROM sys.dm_exec_query_stats AS
deqs
            CROSS
APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY deqs.last_execution_time
DESC
Note:
■ Logical Reads — Represents the number of pages read from the data cache.
■ Physical Reads — If the required page is not in cache, it will be read from disk.
■ Elapsed Time — CPU time + waits
 
No comments:
Post a Comment