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: docs/tools/sql-server-profiler/analyze-deadlocks-with-sql-server-profiler.md
+48-46Lines changed: 48 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,56 +4,58 @@ titleSuffix: SQL Server Profiler
4
4
description: Identify the cause of a deadlock by replaying and displaying deadlock events for analysis in SQL Server Profiler and by generating wait-for graphs.
5
5
author: rwestMSFT
6
6
ms.author: randolphwest
7
-
ms.date: 03/03/2017
7
+
ms.date: 06/05/2025
8
8
ms.service: sql
9
9
ms.subservice: profiler
10
10
ms.topic: conceptual
11
11
ms.collection:
12
12
- data-tools
13
13
---
14
14
15
-
# Analyze Deadlocks with SQL Server Profiler
16
-
17
-
[!INCLUDE [SQL Server Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdbmi.md)]
18
-
19
-
Use [!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)] to identify the cause of a deadlock. A deadlock occurs when there is a cyclic dependency between two or more threads, or processes, for some set of resources within SQL Server. Using [!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)], you can create a trace that records, replays, and displays deadlock events for analysis.
20
-
21
-
To trace deadlock events, add the **Deadlock graph** event class to a trace. This event class populates the **TextData** data column in the trace with XML data about the process and objects that are involved in the deadlock. [!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)] can extract the XML document to a deadlock XML (.xdl) file which you can view later in SQL Server Management Studio. You can configure [!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)] to extract **Deadlock graph** events to a single file that contains all **Deadlock graph** events, or to separate files. This extraction can be done in any of the following ways:
22
-
23
-
- At trace configuration time, using the **Events Extraction Settings** tab. Note that this tab does not appear until you select the **Deadlock graph** event on the **Events Selection** tab.
24
-
25
-
- Using the **Extract SQL Server Events** option on the **File** menu.
26
-
27
-
- Individual events can also be extracted and saved by right-clicking a specific event and choosing **Extract Event Data**.
28
-
29
-
## Deadlock Graphs
30
-
[!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)] and [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] use a deadlock wait-for graph to describe a deadlock. The deadlock wait-for graph contains process nodes, resource nodes, and edges representing the relationships between the processes and the resources. The components of wait-for graphs are defined in the following table:
31
-
32
-
Process node
33
-
A thread that performs a task; for example, INSERT, UPDATE, or DELETE.
34
-
35
-
Resource node
36
-
A database object; for example, a table, index, or row.
37
-
38
-
Edge
39
-
A relationship between a process and a resource. A **request** edge occurs when a process waits for a resource. An **owner** edge occurs when a resource waits for a process. The lock mode is included in the edge description. For example, **Mode: X**.
40
-
41
-
## Deadlock Process Node
42
-
In a wait-for graph, the process node contains information about the process. The following table explains the components of a process.
43
-
44
-
|Component|Definition|
45
-
|---------------|----------------|
46
-
|Server process Id|Session ID (SPID), a server assigned identifier for the process owning the lock.|
47
-
|Server batch Id|Server batch identifier (SBID).|
48
-
|Execution context Id|Execution context identifier (ECID). The execution context ID of a given thread associated with a specific session ID.<br /><br /> ECID = {0,1,2,3, *...n*}, where 0 always represents the main or parent thread, and {1,2,3, *...n*} represent the subthreads.|
49
-
|Deadlock priority|Deadlock priority for the process. For more information about possible values, see [SET DEADLOCK_PRIORITY (Transact-SQL)](../../t-sql/statements/set-deadlock-priority-transact-sql.md).|
50
-
|Log Used|Amount of log space used by the process.|
51
-
|Owner Id|Transaction ID for the processes which are using transactions and currently waiting on a lock.|
52
-
|Transaction descriptor|Pointer to the transaction descriptor that describes the state of the transaction.|
53
-
|Input buffer|Input buffer of the current process, defines the type of event and the statement being executed. Possible values include:<br /><br /> **Language**<br /><br /> **RPC**<br /><br /> **None**|
In a deadlock, two processes are each waiting for a resource held by the other process. In a deadlock graph, the resources are displayed as resource nodes.
58
-
59
-
15
+
# Analyze deadlocks with SQL Server Profiler
16
+
17
+
[!INCLUDE [SQL Server Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdbmi.md)]
18
+
19
+
Use [!INCLUDE [ssSqlProfiler](../../includes/sssqlprofiler-md.md)] to identify the cause of a deadlock. A deadlock occurs when there's a cyclic dependency between two or more threads, or processes, for some set of resources within SQL Server. Using [!INCLUDE [ssSqlProfiler](../../includes/sssqlprofiler-md.md)], you can create a trace that records, replays, and displays deadlock events for analysis.
20
+
21
+
To trace deadlock events, add the **Deadlock graph** event class to a trace. This event class populates the **TextData** data column in the trace with XML data about the process and objects that are involved in the deadlock. [!INCLUDE [ssSqlProfiler](../../includes/sssqlprofiler-md.md)] can extract the XML document to a deadlock XML (.xdl) file which you can view later in SQL Server Management Studio. You can configure [!INCLUDE [ssSqlProfiler](../../includes/sssqlprofiler-md.md)] to extract **Deadlock graph** events to a single file that contains all **Deadlock graph** events, or to separate files. This extraction can be done in any of the following ways:
22
+
23
+
- At trace configuration time, using the **Events Extraction Settings** tab. This tab doesn't appear until you select the **Deadlock graph** event on the **Events Selection** tab.
24
+
25
+
- Using the **Extract SQL Server Events** option on the **File** menu.
26
+
27
+
- Individual events can also be extracted and saved by right-clicking a specific event and choosing **Extract Event Data**.
28
+
29
+
## Deadlock graphs
30
+
31
+
[!INCLUDE [ssSqlProfiler](../../includes/sssqlprofiler-md.md)] and [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)] use a deadlock wait-for graph to describe a deadlock. The deadlock wait-for graph contains process nodes, resource nodes, and edges representing the relationships between the processes and the resources. The components of wait-for graphs are defined in the following table:
32
+
33
+
| Node | Description |
34
+
| --- | --- |
35
+
| Process node | A thread that performs a task; for example, `INSERT`, `UPDATE`, or `DELETE`. |
36
+
| Resource node | A database object; for example, a table, index, or row. |
37
+
| Edge | A relationship between a process and a resource. A **request** edge occurs when a process waits for a resource. An **owner** edge occurs when a resource waits for a process. The lock mode is included in the edge description. For example, **Mode: X**. |
38
+
39
+
## Deadlock process node
40
+
41
+
In a wait-for graph, the process node contains information about the process. The following table explains the components of a process.
42
+
43
+
| Component | Definition |
44
+
| --- | --- |
45
+
| Server process ID | Session ID (SPID), a server assigned identifier for the process owning the lock. |
46
+
| Server batch ID | Server batch identifier (SBID). |
47
+
| Execution context ID | Execution context identifier (ECID). The execution context ID of a given thread associated with a specific session ID.<br /><br />ECID = { 0, 1, 2, 3, *...n* }, where 0 always represents the main or parent thread, and { 1, 2, 3, *...n* } represent the subthreads. |
48
+
| Deadlock priority | Deadlock priority for the process. For more information about possible values, see [SET DEADLOCK_PRIORITY](../../t-sql/statements/set-deadlock-priority-transact-sql.md). |
49
+
| Log Used | Amount of log space used by the process. |
50
+
| Owner Id | Transaction ID for the processes which are using transactions and currently waiting on a lock. |
51
+
| Transaction descriptor | Pointer to the transaction descriptor that describes the state of the transaction. |
52
+
| Input buffer | Input buffer of the current process, defines the type of event and the statement being executed. Possible values include:<br /><br />**Language**<br />**RPC**<br />**None**|
53
+
| Statement | Type of statement. Possible values are:<br /><br />**NOP**<br />**SELECT**<br />**UPDATE**<br />**INSERT**<br />**DELETE**<br />**Unknown**|
54
+
55
+
## Deadlock resource node
56
+
57
+
In a deadlock, two processes are each waiting for a resource held by the other process. In a deadlock graph, the resources are displayed as resource nodes.
Copy file name to clipboardExpand all lines: docs/tools/sql-server-profiler/analyze-queries-with-showplan-results-in-sql-server-profiler.md
+34-33Lines changed: 34 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,43 +4,44 @@ titleSuffix: SQL Server Profiler
4
4
description: Find out how to extract Showplan events from a trace so that SQL Server Profiler displays query plan information. View a table of Showplan trace events.
5
5
author: rwestMSFT
6
6
ms.author: randolphwest
7
-
ms.date: 03/14/2017
7
+
ms.date: 06/05/2025
8
8
ms.service: sql
9
9
ms.subservice: profiler
10
10
ms.topic: conceptual
11
11
ms.collection:
12
12
- data-tools
13
13
---
14
14
15
-
# Analyze Queries with SHOWPLAN Results in SQL Server Profiler
16
-
17
-
[!INCLUDE [SQL Server Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdbmi.md)]
18
-
You can add Showplan event classes to a trace definition that cause [!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)] to gather and display query plan information in the trace. It is also possible to extract Showplan events from the other events collected in the trace and to save these Showplan events in a separate XML file.
19
-
20
-
Extracting Showplan events from the trace can be done in any of the following ways:
21
-
22
-
- At trace configuration time, using the **Events Extraction Settings** tab. Note that this tab does not appear until you select a one of the Showplan events on the **Events Selection** tab.
23
-
24
-
- Using the **Extract SQL Server Events** option on the **File** menu.
25
-
26
-
- By extracting and saving individual events by right-clicking a specific event and choosing **Extract Event Data**.
27
-
28
-
## Showplan Events
29
-
The Showplan trace events are listed and described in the following table.
30
-
31
-
|Event name|Description|
32
-
|----------------|-----------------|
33
-
|**Performance statistics**|Indicates the first time a compiled Showplan is cached, when it is recompiled, and when it is dropped from the plan cache. The **TextData** column contains the Showplan in XML format. For more information, see [Performance Statistics Event Class](../../relational-databases/event-classes/performance-statistics-event-class.md).|
34
-
|**Showplan All**|Displays the query plan with full compilation details of the executed [!INCLUDE[tsql](../../includes/tsql-md.md)] statement. For example, it might display costing estimates and column lists. For more information, see [Showplan All Event Class](../../relational-databases/event-classes/showplan-all-event-class.md).|
35
-
|**Showplan All For Query Compile**|Occurs when a query is compiled or recompiled on [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. This is the compile time counterpart of the **Showplan All** event. **Showplan All** occurs when a query is executed. **Showplan All For Query Compile** occurs when a query is compiled. For more information, see [Showplan All for Query Compile Event Class](../../relational-databases/event-classes/showplan-all-for-query-compile-event-class.md).|
36
-
|**Showplan Statistics Profile**|Displays the query plan with full run-time details of the [!INCLUDE[tsql](../../includes/tsql-md.md)] statement being executed, including the actual number of rows passing through each operation. For more information, see [Showplan Statistics Profile Event Class](../../relational-databases/event-classes/showplan-statistics-profile-event-class.md).|
37
-
|**Showplan Text**|Displays as binary data the query plan tree of the [!INCLUDE[tsql](../../includes/tsql-md.md)] statement being executed. For more information, see [Showplan Text Event Class](../../relational-databases/event-classes/showplan-text-event-class.md).|
38
-
|**Showplan Text (Unencoded)**|Displays as text the query plan tree of the [!INCLUDE[tsql](../../includes/tsql-md.md)] statement being executed. This event class displays the same information as Showplan Text, except that this event class displays text instead of binary data. For more information, see [Showplan Text (Unencoded) Event Class](../../relational-databases/event-classes/showplan-text-unencoded-event-class.md).|
39
-
|**Showplan XML**|Displays the query plan with full data collected during query optimization. This event is generated only when a query plan is optimized. For more information, see [Showplan XML Event Class](../../relational-databases/event-classes/showplan-xml-event-class.md).|
40
-
|**Showplan XML For Query Compile**|Displays the query plan when the query is compiled. For more information, see [Showplan XML for Query Compile Event Class](../../relational-databases/event-classes/showplan-xml-for-query-compile-event-class.md).|
41
-
|**Showplan XML Statistics Profile**|Displays the query plan with full run-time details in XML format. For example, this event class captures the number of rows passing through each operator of the [!INCLUDE[tsql](../../includes/tsql-md.md)] statement that is executed. For more information, see [Showplan XML Statistics Profile Event Class](../../relational-databases/event-classes/showplan-xml-statistics-profile-event-class.md).|
# Analyze queries with SHOWPLAN results in SQL Server Profiler
16
+
17
+
[!INCLUDE [SQL Server Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdbmi.md)]
18
+
19
+
You can add Showplan event classes to a trace definition that cause [!INCLUDE [ssSqlProfiler](../../includes/sssqlprofiler-md.md)] to gather and display query plan information in the trace. It's also possible to extract Showplan events from the other events collected in the trace and to save these Showplan events in a separate XML file.
20
+
21
+
Extracting Showplan events from the trace can be done in any of the following ways:
22
+
23
+
- At trace configuration time, using the **Events Extraction Settings** tab. This tab doesn't appear until you select a one of the Showplan events on the **Events Selection** tab.
24
+
25
+
- Using the **Extract SQL Server Events** option on the **File** menu.
26
+
27
+
- By extracting and saving individual events by right-clicking a specific event and choosing **Extract Event Data**.
28
+
29
+
## Showplan events
30
+
31
+
The Showplan trace events are listed and described in the following table.
32
+
33
+
| Event name | Description |
34
+
| --- | --- |
35
+
|**Performance statistics**| Indicates the first time a compiled Showplan is cached, when it's recompiled, and when it's dropped from the plan cache. The **TextData** column contains the Showplan in XML format. For more information, see [Performance Statistics Event Class](../../relational-databases/event-classes/performance-statistics-event-class.md). |
36
+
|**Showplan All**| Displays the query plan with full compilation details of the executed [!INCLUDE [tsql](../../includes/tsql-md.md)] statement. For example, it might display costing estimates and column lists. For more information, see [Showplan All Event Class](../../relational-databases/event-classes/showplan-all-event-class.md). |
37
+
|**Showplan All For Query Compile**| Occurs when a query is compiled or recompiled on [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. This is the compile time counterpart of the **Showplan All** event. **Showplan All** occurs when a query is executed. **Showplan All For Query Compile** occurs when a query is compiled. For more information, see [Showplan All for Query Compile Event Class](../../relational-databases/event-classes/showplan-all-for-query-compile-event-class.md). |
38
+
|**Showplan Statistics Profile**| Displays the query plan with full run-time details of the [!INCLUDE [tsql](../../includes/tsql-md.md)] statement being executed, including the actual number of rows passing through each operation. For more information, see [Showplan Statistics Profile Event Class](../../relational-databases/event-classes/showplan-statistics-profile-event-class.md). |
39
+
|**Showplan Text**| Displays as binary data the query plan tree of the [!INCLUDE [tsql](../../includes/tsql-md.md)] statement being executed. For more information, see [Showplan Text Event Class](../../relational-databases/event-classes/showplan-text-event-class.md). |
40
+
|**Showplan Text (Unencoded)**| Displays as text the query plan tree of the [!INCLUDE [tsql](../../includes/tsql-md.md)] statement being executed. This event class displays the same information as Showplan Text, except that this event class displays text instead of binary data. For more information, see [Showplan Text (Unencoded) Event Class](../../relational-databases/event-classes/showplan-text-unencoded-event-class.md). |
41
+
|**Showplan XML**| Displays the query plan with full data collected during query optimization. This event is generated only when a query plan is optimized. For more information, see [Showplan XML Event Class](../../relational-databases/event-classes/showplan-xml-event-class.md). |
42
+
|**Showplan XML For Query Compile**| Displays the query plan when the query is compiled. For more information, see [Showplan XML for Query Compile Event Class](../../relational-databases/event-classes/showplan-xml-for-query-compile-event-class.md). |
43
+
|**Showplan XML Statistics Profile**| Displays the query plan with full run-time details in XML format. For example, this event class captures the number of rows passing through each operator of the [!INCLUDE [tsql](../../includes/tsql-md.md)] statement that is executed. For more information, see [Showplan XML Statistics Profile Event Class](../../relational-databases/event-classes/showplan-xml-statistics-profile-event-class.md). |
Copy file name to clipboardExpand all lines: docs/tools/sql-server-profiler/clear-a-trace-window-sql-server-profiler.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,28 +4,28 @@ titleSuffix: SQL Server Profiler
4
4
description: Find out how to clear the trace window that captures event data in SQL Server Profiler without clearing any trace files or tables.
5
5
author: rwestMSFT
6
6
ms.author: randolphwest
7
-
ms.date: 03/01/2017
7
+
ms.date: 06/05/2025
8
8
ms.service: sql
9
9
ms.subservice: profiler
10
10
ms.topic: how-to
11
11
ms.collection:
12
12
- data-tools
13
13
---
14
14
15
-
# Clear a Trace Window (SQL Server Profiler)
16
-
17
-
[!INCLUDE [SQL Server Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdbmi.md)]
18
-
This topic describes how to clear the trace window for a trace that is running by using [!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)].
19
-
20
-
### To clear a trace window
21
-
22
-
1. Select the trace window you want to clear.
23
-
24
-
2. On the **Edit**menu, click **Clear Trace Window**.
25
-
26
-
The contents of the trace window are removed. Note that if the trace file or table has been saved, the contents of the file or table remains unchanged.
27
-
28
-
## See Also
29
-
[SQL Server Profiler](../../tools/sql-server-profiler/sql-server-profiler.md)
30
-
31
-
15
+
# Clear a trace window (SQL Server Profiler)
16
+
17
+
[!INCLUDE [SQL Server Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdbmi.md)]
18
+
19
+
This article describes how to clear the trace window for a trace that is running by using [!INCLUDE [ssSqlProfiler](../../includes/sssqlprofiler-md.md)].
20
+
21
+
## Clear a trace window
22
+
23
+
1. Select the trace window you want to clear.
24
+
25
+
1. On the **Edit** menu, select **Clear Trace Window**.
26
+
27
+
The contents of the trace window are removed. If the trace file or table has been saved, the contents of the file or table remains unchanged.
0 commit comments