You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns information about all queries that have requested and are waiting for a memory grant or have been given a memory grant. Queries that do not require a memory grant will not appear in this view. For example, sort and hash join operations have memory grants for query execution, while queries without an **ORDER BY** clause will not have a memory grant.
27
+
Returns information about all queries that have requested and are waiting for a memory grant or have been given a memory grant. Queries that do not require a memory grant will not appear in this view. For example, sort and hash join operations have memory grants for query execution, while queries without an `ORDER BY` clause will not have a memory grant.
29
28
30
-
In [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], dynamic management views cannot expose information that would impact database containment or expose information about other databases the user has access to. To avoid exposing this information, every row that contains data that doesn't belong to the connected tenant is filtered out. In addition, the values in the columns **scheduler_id**, **wait_order**, **pool_id**, **group_id** are filtered; the column value is set to NULL.
29
+
In [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], dynamic management views cannot expose information that would impact database containment or expose information about other databases the user has access to. To avoid exposing this information, every row that contains data that doesn't belong to the connected tenant is filtered out. In addition, the values in the columns `scheduler_id`, `wait_order`, `pool_id`, `group_id` are filtered; the column value is set to NULL.
31
30
32
31
> [!NOTE]
33
32
> To call this from [!INCLUDE[ssSDWfull](../../includes/sssdwfull-md.md)] or [!INCLUDE[ssPDW](../../includes/sspdw-md.md)], use the name `sys.dm_pdw_nodes_exec_query_memory_grants`. [!INCLUDE[synapse-analytics-od-unsupported-syntax](../../includes/synapse-analytics-od-unsupported-syntax.md)]
|**request_time**|**datetime**|Date and time when this query requested the memory grant.|
42
41
|**grant_time**|**datetime**|Date and time when memory was granted for this query. NULL if memory is not granted yet.|
43
42
|**requested_memory_kb**|**bigint**|Total requested amount of memory in kilobytes.|
44
-
|**granted_memory_kb**|**bigint**|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.|
45
-
|**required_memory_kb**|**bigint**|Minimum memory required to run this query in kilobytes. **requested_memory_kb** is the same or larger than this amount.|
43
+
|**granted_memory_kb**|**bigint**|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.|
44
+
|**required_memory_kb**|**bigint**|Minimum memory required to run this query in kilobytes. `requested_memory_kb` is the same or larger than this amount.|
46
45
|**used_memory_kb**|**bigint**|Physical memory used at this moment in kilobytes.|
47
46
|**max_used_memory_kb**|**bigint**|Maximum physical memory used up to this moment in kilobytes.|
48
47
|**query_cost**|**float**|Estimated query cost.|
49
48
|**timeout_sec**|**int**|Time-out in seconds before this query gives up the memory grant request.|
50
-
|**resource_semaphore_id**|**smallint**|Non-unique ID of the resource semaphore on which this query is waiting.<br /><br /> **Note:** This ID is unique in versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] that are earlier than [!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)]. This change can affect troubleshooting query execution. For more information, see the "Remarks" section later in this topic.|
49
+
|**resource_semaphore_id**|**smallint**|Non-unique ID of the resource semaphore on which this query is waiting.<br /><br /> **Note:** This ID is unique in versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] that are earlier than [!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)]. This change can affect troubleshooting query execution. For more information, see the "Remarks" section later in this article.|
51
50
|**queue_id**|**smallint**|ID of waiting queue where this query waits for memory grants. NULL if the memory is already granted.|
52
-
|**wait_order**|**int**|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.|
51
+
|**wait_order**|**int**|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.|
53
52
|**is_next_candidate**|**bit**|Candidate for next memory grant.<br /><br /> 1 = Yes<br /><br /> 0 = No<br /><br /> NULL = Memory is already granted.|
54
53
|**wait_time_ms**|**bigint**|Wait time in milliseconds. NULL if the memory is already granted.|
55
-
|**plan_handle**|**varbinary(64)**|Identifier for this query plan. Use **sys.dm_exec_query_plan** to extract the actual XML plan.|
56
-
|**sql_handle**|**varbinary(64)**|Identifier for [!INCLUDE[tsql](../../includes/tsql-md.md)] text for this query. Use **sys.dm_exec_sql_text** to get the actual [!INCLUDE[tsql](../../includes/tsql-md.md)] text.|
54
+
|**plan_handle**|**varbinary(64)**|Identifier for this query plan. Use `sys.dm_exec_query_plan` to extract the actual XML plan.|
55
+
|**sql_handle**|**varbinary(64)**|Identifier for [!INCLUDE[tsql](../../includes/tsql-md.md)] text for this query. Use `sys.dm_exec_sql_text` to get the actual [!INCLUDE[tsql](../../includes/tsql-md.md)] text.|
57
56
|**group_id**|**int**|ID for the workload group where this query is running.|
58
57
|**pool_id**|**int**|ID of the resource pool that this workload group belongs to.|
59
58
|**is_small**|**tinyint**|When set to 1, indicates that this grant uses the small resource semaphore. When set to 0, indicates that a regular semaphore is used.|
@@ -70,17 +69,24 @@ On [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)], requires `VIEW
70
69
On [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], requires the `VIEW DATABASE STATE` permission in the database.
71
70
72
71
## Remarks
73
-
A typical debugging scenario for query time-out may look like the following:
72
+
73
+
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.
74
+
75
+
The Resource Governor feature enables a database administrator to distribute server resources among resource pools, up to a maximum of 64 pools. Beginning with [!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)], each pool behaves like a small independent server instance and requires two 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 [!INCLUDE[ssVersion2005](../../includes/ssversion2005-md.md)].
76
+
77
+
## Examples
78
+
79
+
A typical debugging scenario for query time-out may investigate the following:
74
80
75
81
- Check overall system memory status using [sys.dm_os_memory_clerks](../../relational-databases/system-dynamic-management-views/sys-dm-os-memory-clerks-transact-sql.md), [sys.dm_os_sys_info](../../relational-databases/system-dynamic-management-views/sys-dm-os-sys-info-transact-sql.md), and various performance counters.
76
82
77
-
- Check for query-execution memory reservations in **sys.dm_os_memory_clerks** where `type = 'MEMORYCLERK_SQLQERESERVATIONS'`.
83
+
- Check for query-execution memory reservations in `sys.dm_os_memory_clerks` where `type = 'MEMORYCLERK_SQLQERESERVATIONS'`.
78
84
79
-
- Check for queries waiting<sup>1</sup> for grants using **sys.dm_exec_query_memory_grants**.
85
+
- Check for queries waiting<sup>1</sup> for grants using `sys.dm_exec_query_memory_grants`:
80
86
81
87
```sql
82
88
--Find all queries waiting in the memory queue
83
-
SELECT*FROMsys.dm_exec_query_memory_grantswhere grant_time is null
89
+
SELECT*FROMsys.dm_exec_query_memory_grantsWHERE grant_time IS NULL;
84
90
```
85
91
86
92
<sup>1</sup>In this scenario, the wait type is typically RESOURCE_SEMAPHORE. For more information, see [sys.dm_os_wait_stats (Transact-SQL)](../../relational-databases/system-dynamic-management-views/sys-dm-os-wait-stats-transact-sql.md).
@@ -95,27 +101,39 @@ On [!INCLUDE[ssSDSfull](../../includes/sssdsfull-md.md)], requires the `VIEW DAT
95
101
GO
96
102
```
97
103
98
-
- Further examine memory-intensive queries using [sys.dm_exec_requests](../../relational-databases/system-dynamic-management-views/sys-dm-exec-requests-transact-sql.md).
99
-
100
-
```sql
101
-
--Find top 5 queries by average CPU time
102
-
SELECT TOP 5 total_worker_time/execution_count AS [Avg CPU Time],
- If a runaway query is suspected, examine the Showplan from [sys.dm_exec_query_plan](../../relational-databases/system-dynamic-management-views/sys-dm-exec-query-plan-transact-sql.md) and batch textfrom [sys.dm_exec_sql_text](../../relational-databases/system-dynamic-management-views/sys-dm-exec-sql-text-transact-sql.md).
111
-
112
-
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.
113
-
114
-
The Resource Governor feature enables a database administrator to distribute server resources among resource pools, up to a maximum of 64 pools. Beginning with [!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)], 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 20times more than the rows that are returned in [!INCLUDE[ssVersion2005](../../includes/ssversion2005-md.md)].
[Execution Related Dynamic Management Views and Functions (Transact-SQL)](../../relational-databases/system-dynamic-management-views/execution-related-dynamic-management-views-and-functions-transact-sql.md)
120
-
[Thread and Task Architecture Guide](../../relational-databases/thread-and-task-architecture-guide.md)
121
-
104
+
- If a runaway query is suspected, examine the Showplan in the `query_plan` column from [sys.dm_exec_query_plan](../../relational-databases/system-dynamic-management-views/sys-dm-exec-query-plan-transact-sql.md) and query batch `text`from [sys.dm_exec_sql_text](../../relational-databases/system-dynamic-management-views/sys-dm-exec-sql-text-transact-sql.md). Further examine memory-intensive queries currently executing, using [sys.dm_exec_requests](../../relational-databases/system-dynamic-management-views/sys-dm-exec-requests-transact-sql.md).
- [Execution Related Dynamic Management Views and Functions (Transact-SQL)](../../relational-databases/system-dynamic-management-views/execution-related-dynamic-management-views-and-functions-transact-sql.md)
137
+
- [Thread and Task Architecture Guide](../../relational-databases/thread-and-task-architecture-guide.md)
0 commit comments