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
Copy file name to clipboardExpand all lines: articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-manage-monitor.md
+38-41Lines changed: 38 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,19 @@
1
1
---
2
-
title: Monitor your dedicated SQL pool workload using DMVs
2
+
title: Monitor your dedicated SQL pool workload using DMVs
3
3
description: Learn how to monitor your Azure Synapse Analytics dedicated SQL pool workload and query execution using DMVs.
4
4
author: WilliamDAssafMSFT
5
-
manager: craigg
5
+
ms.author: wiassaf
6
+
ms.reviewer: kecona
7
+
ms.date: 11/09/2022
6
8
ms.service: synapse-analytics
9
+
ms.subservice: sql-dw
7
10
ms.topic: conceptual
8
-
ms.subservice: sql-dw
9
-
ms.date: 11/15/2021
10
-
ms.author: wiassaf
11
-
ms.reviewer: wiassaf
12
11
ms.custom: synapse-analytics
13
12
---
14
13
15
14
# Monitor your Azure Synapse Analytics dedicated SQL pool workload using DMVs
16
15
17
-
This article describes how to use Dynamic Management Views (DMVs) to monitor your workload including investigating query execution in SQL pool.
16
+
This article describes how to use Dynamic Management Views (DMVs) to monitor your workload including investigating query execution in a dedicated SQL pool.
18
17
19
18
## Permissions
20
19
@@ -26,7 +25,7 @@ GRANT VIEW DATABASE STATE TO myuser;
26
25
27
26
## Monitor connections
28
27
29
-
All logins to your data warehouse are logged to [sys.dm_pdw_exec_sessions](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-exec-sessions-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true). This DMV contains the last 10,000 logins. The session_id is the primary key and is assigned sequentially for each new logon.
28
+
All logins to your data warehouse are logged to [sys.dm_pdw_exec_sessions](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-exec-sessions-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true). This DMV contains the last 10,000 logins. The `session_id` is the primary key and is assigned sequentially for each new login.
30
29
31
30
```sql
32
31
-- Other Active Connections
@@ -35,9 +34,9 @@ SELECT * FROM sys.dm_pdw_exec_sessions where status <> 'Closed' and session_id <
35
34
36
35
## Monitor query execution
37
36
38
-
All queries executed on SQL pool are logged to [sys.dm_pdw_exec_requests](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-exec-requests-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true). This DMV contains the last 10,000 queries executed. The request_id uniquely identifies each query and is the primary key for this DMV. The request_id is assigned sequentially for each new query and is prefixed with QID, which stands for query ID. Querying this DMV for a given session_id shows all queries for a given logon.
37
+
All queries executed on SQL pool are logged to [sys.dm_pdw_exec_requests](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-exec-requests-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true). This DMV contains the last 10,000 queries executed. The `request_id` uniquely identifies each query and is the primary key for this DMV. The `request_id` is assigned sequentially for each new query and is prefixed with QID, which stands for query ID. Querying this DMV for a given `session_id` shows all queries for a given login.
39
38
40
-
> [!NOTE]
39
+
> [!NOTE]
41
40
> Stored procedures use multiple Request IDs. Request IDs are assigned in sequential order.
42
41
43
42
Here are steps to follow to investigate query execution plans and times for a particular query.
@@ -56,14 +55,13 @@ ORDER BY submit_time DESC;
56
55
SELECT TOP 10*
57
56
FROMsys.dm_pdw_exec_requests
58
57
ORDER BY total_elapsed_time DESC;
59
-
60
58
```
61
59
62
60
From the preceding query results, **note the Request ID** of the query that you would like to investigate.
63
61
64
62
Queries in the **Suspended** state can be queued due to a large number of active running queries. These queries also appear in the [sys.dm_pdw_waits](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-waits-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true). In that case, look for waits such as UserConcurrencyResourceType. For information on concurrency limits, see [Memory and concurrency limits](memory-concurrency-limits.md) or [Resource classes for workload management](resource-classes-for-workload-management.md). Queries can also wait for other reasons such as for object locks. If your query is waiting for a resource, see [Investigating queries waiting for resources](#monitor-waiting-queries) further down in this article.
65
63
66
-
To simplify the lookup of a query in the [sys.dm_pdw_exec_requests](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-exec-requests-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) table, use [LABEL](/sql/t-sql/queries/option-clause-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) to assign a comment to your query, which can be looked up in the sys.dm_pdw_exec_requests view.
64
+
To simplify the lookup of a query in the [sys.dm_pdw_exec_requests](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-exec-requests-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) table, use [LABEL](/sql/t-sql/queries/option-clause-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) to assign a comment to your query, which can be looked up in the `sys.dm_pdw_exec_requests` view.
67
65
68
66
```sql
69
67
-- Query with Label
@@ -94,7 +92,7 @@ ORDER BY step_index;
94
92
95
93
When a DSQL plan is taking longer than expected, the cause can be a complex plan with many DSQL steps or just one step taking a long time. If the plan is many steps with several move operations, consider optimizing your table distributions to reduce data movement. The [Table distribution](sql-data-warehouse-tables-distribute.md) article explains why data must be moved to solve a query. The article also explains some distribution strategies to minimize data movement.
96
94
97
-
To investigate further details about a single step, the *operation_type* column of the long-running query step and note the **Step Index**:
95
+
To investigate further details about a single step, the `operation_type` column of the long-running query step and note the **Step Index**:
98
96
99
97
* Proceed with Step 3 for **SQL operations**: OnOperation, RemoteOperation, ReturnOperation.
100
98
* Proceed with Step 4 for **Data Movement operations**: ShuffleMoveOperation, BroadcastMoveOperation, TrimMoveOperation, PartitionMoveOperation, MoveOperation, CopyOperation.
@@ -132,8 +130,8 @@ SELECT * FROM sys.dm_pdw_dms_workers
132
130
WHERE request_id ='QID####'AND step_index =2;
133
131
```
134
132
135
-
* Check the *total_elapsed_time* column to see if a particular distribution is taking significantly longer than others for data movement.
136
-
* For the long-running distribution, check the *rows_processed* column to see if the number of rows being moved from that distribution is significantly larger than others. If so, this finding might indicate skew of your underlying data. One cause for data skew is distributing on a column with many NULL values (whose rows will all land in the same distribution). Prevent slow queries by avoiding distribution on these types of columns or filtering your query to eliminate NULLs when possible.
133
+
* Check the `total_elapsed_time` column to see if a particular distribution is taking significantly longer than others for data movement.
134
+
* For the long-running distribution, check the `rows_processed` column to see if the number of rows being moved from that distribution is significantly larger than others. If so, this finding might indicate skew of your underlying data. One cause for data skew is distributing on a column with many NULL values (whose rows will all land in the same distribution). Prevent slow queries by avoiding distribution on these types of columns or filtering your query to eliminate NULLs when possible.
137
135
138
136
If the query is running, you can use [DBCC PDW_SHOWEXECUTIONPLAN](/sql/t-sql/database-console-commands/dbcc-pdw-showexecutionplan-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) to retrieve the SQL Server estimated plan from the SQL Server plan cache for the currently running SQL Step within a particular distribution.
139
137
@@ -155,10 +153,10 @@ If you discover that your query is not making progress because it is waiting for
155
153
-- Replace request_id with value from Step 1.
156
154
157
155
SELECTwaits.session_id,
158
-
waits.request_id,
156
+
waits.request_id,
159
157
requests.command,
160
158
requests.status,
161
-
requests.start_time,
159
+
requests.start_time,
162
160
waits.type,
163
161
waits.state,
164
162
waits.object_type,
@@ -174,11 +172,11 @@ If the query is actively waiting on resources from another query, then the state
174
172
175
173
## Monitor tempdb
176
174
177
-
Tempdb is used to hold intermediate results during query execution. High utilization of the tempdb database can lead to slow query performance. For every DW100c configured, 399 GB of tempdb space is allocated (DW1000c would have 3.99 TB of total tempdb space). Below are tips for monitoring tempdb usage and for decreasing tempdb usage in your queries.
175
+
The `tempdb` database is used to hold intermediate results during query execution. High utilization of the `tempdb` database can lead to slow query performance. For every DW100c configured, 399 GB of `tempdb` space is allocated (DW1000c would have 3.99 TB of total `tempdb` space). Below are tips for monitoring `tempdb` usage and for decreasing `tempdb` usage in your queries.
178
176
179
-
### Monitoring tempdb with views
177
+
### Monitor tempdb with views
180
178
181
-
To monitor tempdb usage, first install the [microsoft.vw_sql_requests](https://github.com/Microsoft/sql-data-warehouse-samples/blob/master/solutions/monitoring/scripts/views/microsoft.vw_sql_requests.sql) view from the [Microsoft Toolkit for SQL pool](https://github.com/Microsoft/sql-data-warehouse-samples/tree/master/solutions/monitoring). You can then execute the following query to see the tempdb usage per node for all executed queries:
179
+
To monitor `tempdb` usage, first install the [microsoft.vw_sql_requests](https://github.com/Microsoft/sql-data-warehouse-samples/blob/master/solutions/monitoring/scripts/views/microsoft.vw_sql_requests.sql) view from the [Microsoft Toolkit for SQL pool](https://github.com/Microsoft/sql-data-warehouse-samples/tree/master/solutions/monitoring). You can then execute the following query to see the `tempdb` usage per node for all executed queries:
182
180
183
181
```sql
184
182
-- Monitor tempdb
@@ -212,11 +210,14 @@ WHERE DB_NAME(ssu.database_id) = 'tempdb'
212
210
ORDER BYsr.request_id;
213
211
```
214
212
215
-
If you have a query that is consuming a large amount of memory or have received an error message related to the allocation of tempdb, it could be due to a very large [CREATE TABLE AS SELECT (CTAS)](/sql/t-sql/statements/create-table-as-select-azure-sql-data-warehouse) or [INSERT SELECT](/sql/t-sql/statements/insert-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) statement running that is failing in the final data movement operation. This can usually be identified as a ShuffleMove operation in the distributed query plan right before the final INSERT SELECT. Use [sys.dm_pdw_request_steps](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-request-steps-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) to monitor ShuffleMove operations.
213
+
> [!NOTE]
214
+
> Data Movement uses a hidden database called `QTABLE`. When that database is filled, the query will also return an error message about `tempdb` being out of space. Details about `QTABLE` are not returned in the above query.
216
215
217
-
The most common mitigation is to break your CTAS or INSERT SELECT statement into multiple load statements so the data volume will not exceed the 2TB per node tempdb limit (when at or above DW500c). You can also scale your cluster to a larger size which will spread the tempdb size across more nodes reducing the tempdb on each individual node.
216
+
If you have a query that is consuming a large amount of memory or have received an error message related to the allocation of `tempdb`, it could be due to a very large [CREATE TABLE AS SELECT (CTAS)](/sql/t-sql/statements/create-table-as-select-azure-sql-data-warehouse) or [INSERT SELECT](/sql/t-sql/statements/insert-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) statement running that is failing in the final data movement operation. This can usually be identified as a ShuffleMove operation in the distributed query plan right before the final INSERT SELECT. Use [sys.dm_pdw_request_steps](/sql/relational-databases/system-dynamic-management-views/sys-dm-pdw-request-steps-transact-sql?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json&view=azure-sqldw-latest&preserve-view=true) to monitor ShuffleMove operations.
218
217
219
-
In addition to CTAS and INSERT SELECT statements, large, complex queries running with insufficient memory can spill into tempdb causing queries to fail. Consider running with a larger [resource class](resource-classes-for-workload-management.md) to avoid spilling into tempdb.
218
+
The most common mitigation is to break your CTAS or INSERT SELECT statement into multiple load statements so that the data volume will not exceed the 399 GB per 100DWUc `tempdb` limit. You can also scale your cluster to a larger size to increase how much `tempdb` space you have.
219
+
220
+
In addition to CTAS and INSERT SELECT statements, large, complex queries running with insufficient memory can spill into `tempdb` causing queries to fail. Consider running with a larger [resource class](resource-classes-for-workload-management.md) to avoid spilling into `tempdb`.
220
221
221
222
## Monitor memory
222
223
@@ -282,7 +283,6 @@ GROUP BY t.pdw_node_id, nod.[type]
282
283
The following query provides an approximate estimate of the progress of your load. The query only shows files currently being processed.
283
284
284
285
```sql
285
-
286
286
-- To track bytes and files
287
287
SELECT
288
288
r.command,
@@ -305,57 +305,54 @@ ORDER BY
305
305
306
306
## Monitor query blockings
307
307
308
-
The following query provides the top 500 blocked queries in the environment.
308
+
The following query provides the top 500 blocked queries in the environment.
309
309
310
310
```sql
311
-
312
311
--Collect the top blocking
313
-
SELECT
312
+
SELECT
314
313
TOP 500waiting.request_idAS WaitingRequestId,
315
314
waiting.object_typeAS LockRequestType,
316
315
waiting.object_nameAS ObjectLockRequestName,
317
316
waiting.request_timeAS ObjectLockRequestTime,
318
317
blocking.session_idAS BlockingSessionId,
319
318
blocking.request_idAS BlockingRequestId
320
-
FROM
319
+
FROM
321
320
sys.dm_pdw_waits waiting
322
321
INNER JOINsys.dm_pdw_waits blocking
323
-
ONwaiting.object_type=blocking.object_type
324
-
ANDwaiting.object_name=blocking.object_name
325
-
WHERE
326
-
waiting.state='Queued'
322
+
ONwaiting.object_type=blocking.object_type
323
+
ANDwaiting.object_name=blocking.object_name
324
+
WHERE
325
+
waiting.state='Queued'
327
326
ANDblocking.state='Granted'
328
-
ORDER BY
327
+
ORDER BY
329
328
ObjectLockRequestTime ASC;
330
-
331
-
```
329
+
```
332
330
333
331
## Retrieve query text from waiting and blocking queries
334
332
335
333
The following query provides the query text and identifier for the waiting and blocking queries to easily troubleshoot.
336
334
337
335
```sql
338
-
339
336
-- To retrieve query text from waiting and blocking queries
340
337
341
338
SELECTwaiting.session_idAS WaitingSessionId,
342
339
waiting.request_idAS WaitingRequestId,
343
-
COALESCE(waiting_exec_request.command,waiting_exec_request.command2) AS WaitingExecRequestText,
340
+
COALESCE(waiting_exec_request.command,waiting_exec_request.command2) AS WaitingExecRequestText,
344
341
blocking.session_idAS BlockingSessionId,
345
342
blocking.request_idAS BlockingRequestId,
346
343
COALESCE(blocking_exec_request.command,blocking_exec_request.command2) AS BlockingExecRequestText,
0 commit comments