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/relational-databases/performance/live-query-statistics.md
+58-52Lines changed: 58 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: "Live Query Statistics"
3
3
description: Learn how to view the live execution plan of an active query in SQL Server Management Studio. Use the execution statistics to debug query performance issues.
[!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] provides the ability to view the live execution plan of an active query. This live query plan provides real-time insights into the query execution process as the controls flow from one [query plan operator](../../relational-databases/showplan-logical-and-physical-operators-reference.md) to another. The live query plan displays the overall query progress and operator-level run-time execution statistics such as the number of rows produced, elapsed time, operator progress, etc. Because this data is available in real time without needing to wait for the query to complete, these execution statistics are extremely useful for debugging query performance issues. This feature is available starting with [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)][!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)], however it can work with [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)].
26
+
[!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] provides the ability to view the live execution plan of an active query. This live query plan provides real-time insights into the query execution process as the controls flow from one [query plan operator](../showplan-logical-and-physical-operators-reference.md) to another. The live query plan displays the overall query progress and operator-level run-time execution statistics such as the number of rows produced, elapsed time, operator progress, and more.
27
+
28
+
Because you can access this data in real time without needing to wait for the query to complete, these execution statistics are extremely useful for debugging query performance problems.
29
+
30
+
Internally, live query statistics use the [sys.dm_exec_query_profiles](../system-dynamic-management-views/sys-dm-exec-query-profiles-transact-sql.md) DMV.
26
31
27
-
> [!NOTE]
28
-
> Internally, live query statistics leverages the [sys.dm_exec_query_profiles](../../relational-databases/system-dynamic-management-views/sys-dm-exec-query-profiles-transact-sql.md) DMV.
29
-
30
-
**Applies to**: [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] (starting with [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)]) and [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)].
31
-
32
32
> [!WARNING]
33
-
> This feature is primarily intended for troubleshooting purposes. Using this feature can moderately slow the overall query performance, especially in [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)]. For more information, see [Query Profiling Infrastructure](../../relational-databases/performance/query-profiling-infrastructure.md).
34
-
> This feature can be used with the [Transact-SQL Debugger](../../ssdt/debugger/configure-firewall-rules-before-running-tsql-debugger.md).
35
-
36
-
## To view live query statistics for one query
37
-
38
-
1. To view the live query execution plan, on the tools menu click the **Include Live Query Statistics** icon.
39
-
40
-

41
-
42
-
You can also view access the live query execution plan by right-clicking on a selected query in [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)] and then click **Include Live Query Statistics**.
43
-
44
-

45
-
46
-
2. Now execute the query. The live query plan displays the overall query progress and the run-time execution statistics (e.g. elapsed time, progress, etc.) for the query plan operators. The query progress information and execution statistics are periodically updated while query execution is in progress. Use this information to understand the overall query execution process and to debug long running queries, queries that run indefinitely, queries that cause tempdb overflow, and timeout issues.
47
-
48
-

49
-
50
-
## To view live query statistics for any query
51
-
52
-
The live execution plan can also be accessed from the **[Activity Monitor](../../relational-databases/performance-monitor/activity-monitor.md)** by right-clicking on any query in the **Processes** or **Active Expensive Queries** table.
53
-
54
-

55
-
56
-
## Remarks
57
-
The statistics profile infrastructure must be enabled before live query statistics can capture information about the progress of queries. Depending on the version, the overhead may be significant. For more information on this overhead, see [Query Profiling Infrastructure](../../relational-databases/performance/query-profiling-infrastructure.md).
58
-
59
-
## Permissions
60
-
Requires the database level `SHOWPLAN` permission to populate the **Live Query Statistics** results page, and requires any permissions necessary to execute the query.
61
-
On [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], requires the server level `VIEW SERVER STATE` permission to see the live statistics.
62
-
On [!INCLUDE[ssSDS](../../includes/sssds-md.md)] Premium Tiers, requires the `VIEW DATABASE STATE` permission in the database to see the live statistics. On [!INCLUDE[ssSDS](../../includes/sssds-md.md)] Standard and Basic Tiers, requires the **Server admin** or **Microsoft Entra admin** account to see the live statistics.
63
-
33
+
> This feature is primarily intended for troubleshooting purposes. Using this feature can moderately slow the overall query performance, especially in [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)]. For more information, see [Query Profiling Infrastructure](query-profiling-infrastructure.md).
34
+
> You can use this feature with the [Transact-SQL debugger](../../ssdt/debugger/configure-firewall-rules-before-running-tsql-debugger.md).
1. To view the live query execution plan, on the tools menu, select the **Include Live Query Statistics** icon.
41
+
42
+
:::image type="content" source="../../relational-databases/performance/media/livequerystatstoolbar.png" alt-text="Screenshot from SQL Server Management Studio, showing the Live Query Stats button on toolbar." lightbox="../../relational-databases/performance/media/livequerystatstoolbar.png":::
43
+
44
+
You can also access the live query execution plan by right-clicking on a selected query in [!INCLUDE[ssManStudio](../../includes/ssmanstudio-md.md)] and then selecting **Include Live Query Statistics**.
45
+
46
+
:::image type="content" source="../../relational-databases/performance/media/livequerystatsmenu.png" alt-text="Screenshot from SQL Server Management Studio, showing the Live Query Stats button on popup menu.":::
47
+
48
+
1. Execute the query. The live query plan displays the overall query progress and the run-time execution statistics (for example, elapsed time or progress) for the query plan operators. The query progress information and execution statistics are periodically updated while query execution is in progress. Use this information to understand the overall query execution process and to debug long running queries, queries that run indefinitely, queries that cause `tempdb` overflow, and timeouts.
49
+
50
+
:::image type="content" source="../../relational-databases/performance/media/livequerystatsplan.png" alt-text="Screenshot from SQL Server Management Studio, showing the Live Query Stats button in showplan." lightbox="../../relational-databases/performance/media/livequerystatsplan.png":::
You can also access the live execution plan from **[Activity Monitor](../performance-monitor/activity-monitor.md)** by right-clicking any query in the **Processes** or **Active Expensive Queries** table.
57
+
58
+
:::image type="content" source="../../relational-databases/performance/media/livequerystatsactmon.png" alt-text="Live Query Stats button in Activity Monitor.":::
59
+
60
+
## Remarks
61
+
62
+
You must enable the statistics profile infrastructure before live query statistics can capture information about the progress of queries. Depending on the version, the overhead can be significant. For more information about this overhead, see [Query Profiling Infrastructure](query-profiling-infrastructure.md).
63
+
64
+
## Permissions
65
+
66
+
- To populate the **Live Query Statistics** results page, you need the database level `SHOWPLAN` permission, and any permissions necessary to execute the query.
67
+
- On [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], you need the server level `VIEW SERVER STATE` permission to see the live statistics.
68
+
- On [!INCLUDE[ssSDS](../../includes/sssds-md.md)] Premium Tiers, you need the `VIEW DATABASE STATE` permission in the database to see the live statistics. On [!INCLUDE[ssSDS](../../includes/sssds-md.md)] Standard and Basic Tiers, you need the **Server admin** or **Microsoft Entra admin** account to see the live statistics.
Creates a security policy for [row-level security](../../relational-databases/security/row-level-security.md).
33
+
Creates a security policy for [row-level security](../../relational-databases/security/row-level-security.md) in the SQL Database Engine.
34
+
35
+
:::moniker range="=fabric"
36
+
37
+
Row-level security in Fabric Data Warehouse operates similarly to other SQL Database Engine products. For more information and examples of row-level security in Fabric Data Warehouse or the SQL analytics endpoint, see [Row-level security in Fabric data warehousing](/fabric/data-warehouse/row-level-security).
The name of the security policy. Security policy names must comply with the rules for identifiers and must be unique within the database and to its schema.
63
+
The name of the security policy. Security policy names must follow the rules for identifiers and be unique within the database and its schema.
58
64
59
65
#### *schema_name*
60
66
61
-
Is the name of the schema to which the security policy belongs. *schema_name* is required because of schema binding.
67
+
The name of the schema to which the security policy belongs. *schema_name* is required because of schema binding.
62
68
63
69
#### [ FILTER | BLOCK ]
64
70
65
-
The type of security predicate for the function being bound to the target table. `FILTER` predicates silently filter the rows that are available to read operations. `BLOCK` predicates explicitly block write operations that violate the predicate function.
71
+
The type of security predicate for the function to bind to the target table.
72
+
73
+
-`FILTER` predicates silently filter the rows that are available to read operations.
74
+
-`BLOCK` predicates explicitly block write operations that violate the predicate function.
Is the inline table value function that will be used as a predicate and that will be enforced upon queries against a target table. At most one security predicate can be defined for a particular DML operation against a particular table. The inline table value function must have been created using the `SCHEMABINDING` option.
78
+
The inline table value function that will be used as a predicate and that will be enforced upon queries against a target table. At most one security predicate can be defined for a particular DML operation against a particular table. The inline table value function must have been created using the `SCHEMABINDING` option.
70
79
71
80
#### { *column_name* | *expression* }
72
81
73
-
A column name or expression used as a parameter for the security predicate function. Any column on the target table can be used. An [Expression](../../t-sql/language-elements/expressions-transact-sql.md) can only include constants, built in scalar functions, operators and columns from the target table. A column name or expression needs to be specified for each parameter of the function.
82
+
A column name or expression used as a parameter for the security predicate function. Any column on the target table can be used. An [Expression](../../t-sql/language-elements/expressions-transact-sql.md) can only include constants, built in scalar functions, operators, and columns from the target table. A column name or expression needs to be specified for each parameter of the function.
74
83
75
84
#### *table_schema_name.table_name*
76
85
77
-
Is the target table to which the security predicate will be applied. Multiple disabled security policies can target a single table for a particular DML operation, but only one can be enabled at any given time.
86
+
The target table to which the security predicate will be applied. Multiple disabled security policies can target a single table for a particular DML operation, but only one can be enabled at any given time.
Is the target table to which the security predicate will be applied. Multiple disabled security policies can target a single table, but only one can be enabled at any given time.
106
+
The target table to which the security predicate will be applied. Multiple disabled security policies can target a single table, but only one can be enabled at any given time.
98
107
99
108
100
109
## Remarks
101
110
102
111
When using predicate functions with memory-optimized tables, you must include `SCHEMABINDING` and use the `WITH NATIVE_COMPILATION` compilation hint.
103
112
104
-
Block predicates are evaluated after the corresponding DML operation is executed. Therefore, there is danger that a READ UNCOMMITTED query can see transient values that will be rolled back.
105
-
113
+
Block predicates are evaluated after the corresponding DML operation is executed. Therefore, there is danger that a `READ UNCOMMITTED` query can see transient values that will be rolled back.
114
+
106
115
## Permissions
107
116
108
-
Requires the ALTER ANY SECURITY POLICY permission and ALTER permission on the schema.
117
+
Requires the `ALTER ANY SECURITY POLICY` permission and `ALTER` permission on the schema.
109
118
110
119
Additionally the following permissions are required for each predicate that is added:
111
120
112
-
- SELECT and REFERENCES permissions on the function being used as a predicate.
121
+
-`SELECT` and `REFERENCES` permissions on the function being used as a predicate.
113
122
114
-
- REFERENCES permission on the target table being bound to the policy.
123
+
-`REFERENCES` permission on the target table being bound to the policy.
115
124
116
-
- REFERENCES permission on every column from the target table used as arguments.
125
+
-`REFERENCES` permission on every column from the target table used as arguments.
0 commit comments