Returns information about the queries that have acquired a memory grant or that still require a memory grant to execute. Queries that do not have to wait on a memory grant will not appear in this view.
ID (SPID) of the session where this query is running.
ID of the request. Unique in the context of the session.
ID of the scheduler that is scheduling this query.
Degree of parallelism of this query.
Date and time when this query requested the memory grant.
Date and time when memory was granted for this query. NULL if memory is not granted yet.
Total requested amount of memory in kilobytes.
Total amount of memory actually granted in kilobytes. Can be NULL if the memory is not granted yet. For a typical situation, this value should be the same as requested_memory_kb. For index creation, the server may allow additional on-demand memory beyond initially granted memory.
Minimum memory required to run this query in kilobytes. requested_memory_kb is the same or larger than this amount.
Physical memory used at this moment in kilobytes.
Maximum physical memory used up to this moment in kilobytes.
Estimated query cost.
Time-out in seconds before this query gives up the memory grant request.
Nonunique ID of the resource semaphore on which this query is waiting.
This ID is unique in versions of SQL Server that are earlier than SQL Server 2008. This change can affect troubleshooting query execution. For more information, see the "Remarks" section later in this topic.
ID of waiting queue where this query waits for memory grants. NULL if the memory is already granted.
Sequential order of waiting queries within the specified queue_id. This value can change for a given query if other queries get memory grants or time out. NULL if memory is already granted.
Candidate for next memory grant.
1 = Yes
0 = No
NULL = Memory is already granted.
Wait time in milliseconds. NULL if the memory is already granted.
Identifier for this query plan. Use sys.dm_exec_query_plan to extract the actual XML plan.
Identifier for Transact-SQL text for this query. Use sys.dm_exec_sql_text to get the actual Transact-SQL text.
ID for the workload group where this query is running.
ID of the resource pool that this workload group belongs to.
When set to 1, indicates that this grant uses the small resource semaphore. When set to 0, indicates that a regular semaphore is used.
Size, in kilobytes (KB), of the memory grant to fit everything into physical memory. This is based on the cardinality estimate.
A typical debugging scenario for query time-out may look like the following:
Check for query-execution memory reservations in sys.dm_os_memory_clerks where type = 'MEMORYCLERK_SQLQERESERVATIONS'.
Check for queries waiting for grants using sys.dm_exec_query_memory_grants.
Further examine memory-intensive queries using sys.dm_exec_requests.
Queries that use dynamic management views that include ORDER BY or aggregates may increase memory consumption and thus contribute to the problem they are troubleshooting.
The Resource Governor feature enables a database administrator to distribute server resources among resource pools, up to a maximum of 20 pools. In SQL Server 2008, each pool behaves like a small independent server instance and requires 2 semaphores. The number of rows that are returned from sys.dm_exec_query_resource_semaphores can be up to 20 times more than the rows that are returned in SQL Server 2005.