Most Costly Queries Running Right Now

Out of memory? Use the sys.dm_exec_query_memory_grants DMV to find the heaviest query running right now and kill it.

By memory usage:

SELECT session_id, (requested_memory_kb/1024.AS [Requested Memory (MB)], grant_time, query_costtext
FROM sys.dm_exec_query_memory_grants
CROSS APPLY sys.dm_exec_sql_text(sql_handle) t
ORDER BY requested_memory_kb DESC

By query cost:

SELECT session_id, (requested_memory_kb/1024.AS [Requested Memory (MB)], grant_time, query_costtext
FROM sys.dm_exec_query_memory_grants
CROSS APPLY sys.dm_exec_sql_text(sql_handle) t
ORDER BY query_cost DESC

Leave a Reply

Your email address will not be published. Required fields are marked *


*