Skip to content

Commit e47b327

Browse files
Merge pull request #217427 from KevinConanMSFT/patch-1
Update sql-data-warehouse-manage-monitor.md
2 parents 0d23107 + 62110dd commit e47b327

File tree

1 file changed

+38
-41
lines changed

1 file changed

+38
-41
lines changed

articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-manage-monitor.md

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
---
2-
title: Monitor your dedicated SQL pool workload using DMVs
2+
title: Monitor your dedicated SQL pool workload using DMVs
33
description: Learn how to monitor your Azure Synapse Analytics dedicated SQL pool workload and query execution using DMVs.
44
author: WilliamDAssafMSFT
5-
manager: craigg
5+
ms.author: wiassaf
6+
ms.reviewer: kecona
7+
ms.date: 11/09/2022
68
ms.service: synapse-analytics
9+
ms.subservice: sql-dw
710
ms.topic: conceptual
8-
ms.subservice: sql-dw
9-
ms.date: 11/15/2021
10-
ms.author: wiassaf
11-
ms.reviewer: wiassaf
1211
ms.custom: synapse-analytics
1312
---
1413

1514
# Monitor your Azure Synapse Analytics dedicated SQL pool workload using DMVs
1615

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.
1817

1918
## Permissions
2019

@@ -26,7 +25,7 @@ GRANT VIEW DATABASE STATE TO myuser;
2625

2726
## Monitor connections
2827

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.
3029

3130
```sql
3231
-- Other Active Connections
@@ -35,9 +34,9 @@ SELECT * FROM sys.dm_pdw_exec_sessions where status <> 'Closed' and session_id <
3534

3635
## Monitor query execution
3736

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.
3938

40-
> [!NOTE]
39+
> [!NOTE]
4140
> Stored procedures use multiple Request IDs. Request IDs are assigned in sequential order.
4241
4342
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;
5655
SELECT TOP 10 *
5756
FROM sys.dm_pdw_exec_requests
5857
ORDER BY total_elapsed_time DESC;
59-
6058
```
6159

6260
From the preceding query results, **note the Request ID** of the query that you would like to investigate.
6361

6462
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.
6563

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.
6765

6866
```sql
6967
-- Query with Label
@@ -94,7 +92,7 @@ ORDER BY step_index;
9492

9593
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.
9694

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**:
9896

9997
* Proceed with Step 3 for **SQL operations**: OnOperation, RemoteOperation, ReturnOperation.
10098
* 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
132130
WHERE request_id = 'QID####' AND step_index = 2;
133131
```
134132

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.
137135

138136
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.
139137

@@ -155,10 +153,10 @@ If you discover that your query is not making progress because it is waiting for
155153
-- Replace request_id with value from Step 1.
156154

157155
SELECT waits.session_id,
158-
waits.request_id,
156+
waits.request_id,
159157
requests.command,
160158
requests.status,
161-
requests.start_time,
159+
requests.start_time,
162160
waits.type,
163161
waits.state,
164162
waits.object_type,
@@ -174,11 +172,11 @@ If the query is actively waiting on resources from another query, then the state
174172

175173
## Monitor tempdb
176174

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.
178176

179-
### Monitoring tempdb with views
177+
### Monitor tempdb with views
180178

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:
182180

183181
```sql
184182
-- Monitor tempdb
@@ -212,11 +210,14 @@ WHERE DB_NAME(ssu.database_id) = 'tempdb'
212210
ORDER BY sr.request_id;
213211
```
214212

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.
216215
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.
218217

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`.
220221

221222
## Monitor memory
222223

@@ -282,7 +283,6 @@ GROUP BY t.pdw_node_id, nod.[type]
282283
The following query provides an approximate estimate of the progress of your load. The query only shows files currently being processed.
283284

284285
```sql
285-
286286
-- To track bytes and files
287287
SELECT
288288
r.command,
@@ -305,57 +305,54 @@ ORDER BY
305305

306306
## Monitor query blockings
307307

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.
309309

310310
```sql
311-
312311
--Collect the top blocking
313-
SELECT
312+
SELECT
314313
TOP 500 waiting.request_id AS WaitingRequestId,
315314
waiting.object_type AS LockRequestType,
316315
waiting.object_name AS ObjectLockRequestName,
317316
waiting.request_time AS ObjectLockRequestTime,
318317
blocking.session_id AS BlockingSessionId,
319318
blocking.request_id AS BlockingRequestId
320-
FROM
319+
FROM
321320
sys.dm_pdw_waits waiting
322321
INNER JOIN sys.dm_pdw_waits blocking
323-
ON waiting.object_type = blocking.object_type
324-
AND waiting.object_name = blocking.object_name
325-
WHERE
326-
waiting.state = 'Queued'
322+
ON waiting.object_type = blocking.object_type
323+
AND waiting.object_name = blocking.object_name
324+
WHERE
325+
waiting.state = 'Queued'
327326
AND blocking.state = 'Granted'
328-
ORDER BY
327+
ORDER BY
329328
ObjectLockRequestTime ASC;
330-
331-
```
329+
```
332330

333331
## Retrieve query text from waiting and blocking queries
334332

335333
The following query provides the query text and identifier for the waiting and blocking queries to easily troubleshoot.
336334

337335
```sql
338-
339336
-- To retrieve query text from waiting and blocking queries
340337

341338
SELECT waiting.session_id AS WaitingSessionId,
342339
waiting.request_id AS 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,
344341
blocking.session_id AS BlockingSessionId,
345342
blocking.request_id AS BlockingRequestId,
346343
COALESCE(blocking_exec_request.command,blocking_exec_request.command2) AS BlockingExecRequestText,
347344
waiting.object_name AS Blocking_Object_Name,
348345
waiting.object_type AS Blocking_Object_Type,
349346
waiting.type AS Lock_Type,
350347
waiting.request_time AS Lock_Request_Time,
351-
datediff(ms, waiting.request_time, getdate())/1000.0 AS Blocking_Time_sec
348+
datediff(ms, waiting.request_time, getdate())/1000.0 AS Blocking_Time_sec
352349
FROM sys.dm_pdw_waits waiting
353350
INNER JOIN sys.dm_pdw_waits blocking
354351
ON waiting.object_type = blocking.object_type
355-
AND waiting.object_name = blocking.object_name
352+
AND waiting.object_name = blocking.object_name
356353
INNER JOIN sys.dm_pdw_exec_requests blocking_exec_request
357354
ON blocking.request_id = blocking_exec_request.request_id
358-
INNER JOIN sys.dm_pdw_exec_requests waiting_exec_request
355+
INNER JOIN sys.dm_pdw_exec_requests waiting_exec_request
359356
ON waiting.request_id = waiting_exec_request.request_id
360357
WHERE waiting.state = 'Queued'
361358
AND blocking.state = 'Granted'
@@ -364,4 +361,4 @@ ORDER BY Lock_Request_Time DESC;
364361

365362
## Next steps
366363

367-
For more information about DMVs, see [System views](../sql/reference-tsql-system-views.md).
364+
- For more information about DMVs, see [System views](../sql/reference-tsql-system-views.md).

0 commit comments

Comments
 (0)