SELECT TOP 50
qs.total_physical_reads,qs.execution_count,
qs.total_physical_reads/qs.execution_count AS [avg I/O],
qs. creation_time,
qs.max_elapsed_time,
qs.min_elapsed_time,
SUBSTRING(qt.text,qs.statement_start_offset/2,
(CASE WHEN qs.statement_end_offset=-1
THEN LEN(CONVERT(NVARCHAR(max),qt.text))*2
ELSE qs.statement_end_offset END -qs.statement_start_offset)/2) AS query_text,
qt.dbid,dbname=DB_NAME(qt.dbid),
qt.objectid,
qs.sql_handle,
qs.plan_handle
from sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
ORDER BY qs.total_physical_reads DESC
SELECT TOP 50
qs.total_logical_reads,
qs.execution_count,
qs.max_elapsed_time,
qs.min_elapsed_time,
qs.total_logical_reads/qs.execution_count AS [AVG IO],
SUBSTRING(qt.text,qs.statement_start_offset/2,
(CASE WHEN qs.statement_end_offset=-1
THEN LEN(CONVERT(NVARCHAR(max),qt.text)) *2
ELSE qs.statement_end_offset END -qs.statement_start_offset)/2)
AS query_text,
qt.dbid,
dbname=DB_NAME(qt.dbid),
qt.objectid,
qs.sql_handle,
creation_time,
qs.plan_handle
from sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
ORDER BY qs.total_logical_reads DESC
SELECT Count(*) AS TotalCount FROM [MEM_FlagshipApply]
WITH(NOLOCK) Where (((([Status] = 2) AND ([IsDeleted] = 1)) AND ([MemType] = 0)) AND ([MEMID] <> 6))