Monitors real time query progress while the query is in execution. For example, use this DMV to determine which part of the query is running slow. Join this DMV with other system DMVs using the columns identified in the description field. Or, join this DMV with other performance counters (such as Performance Monitor, xperf) by using the timestamp columns.
The counters returned are per operator per thread. The results are dynamic and do not match the results of existing options such as
SET STATISTICS XML ON which only create output when the query is finished.
|Identifies the session in which this query runs. References dm_exec_sessions.session_id.
|Identifies the target request. References dm_exec_sessions.request_id.
|Is a token that uniquely identifies the batch or stored procedure that the query is part of. References dm_exec_query_stats.sql_handle.
|Is a token that uniquely identifies a query execution plan for a batch that has executed and its plan resides in the plan cache, or is currently executing. References dm_exec_query_stats.plan_handle.
|Physical operator name.
|Identifies an operator node in the query tree.
|Distinguishes the threads (for a parallel query) belonging to the same query operator node.
|Identifies the SQLOS task that this thread is using. References dm_os_tasks.task_address.
|Number of rows returned by the operator so far.
|Number of rewinds so far.
|Number of rebinds so far.
|Number of end of scans so far.
|Estimated number of rows. It can be useful to compare to estimated_row_count to the actual row_count.
|The time, in milliseconds, when the operator was first called.
|The time, in milliseconds, when the operator was last called.
|Timestamp when open (in milliseconds).
|Timestamp when first row was opened (in milliseconds).
|Timestamp when last row was opened(in milliseconds).
|Timestamp when close (in milliseconds).
|Total elapsed time (in milliseconds) used by the target node's operations so far.
|Total CPU time (in milliseconds) use by target node's operations so far.
|ID of the database that contains the object on which the reads and writes are being performed.
|The identifier for the object on which the reads and writes are being performed. References sys.objects.object_id.
|The index (if any) the rowset is opened against.
|Number of table/index scans so far.
|Number of logical reads so far.
|Number of physical reads so far.
|Number of read-aheads so far.
|Number of page-writes so far due to spilling.
|Number of LOB logical reads so far.
|Number of LOB physical reads so far.
|Number of LOB read-aheads so far.
|Number of segment read-aheads so far.
|Number of segments skipped so far.
|Number of rows read by an operator before the residual predicate was applied.
|Applies to: Beginning with SQL Server 2016 (13.x) SP1.
Number of rows estimated to be read by an operator before the residual predicate was applied.
If the query plan node does not have any I/O, all the I/O-related counters are set to NULL.
The I/O-related counters reported by this DMV are more granular than the ones reported by
SET STATISTICS IO in the following two ways:
SET STATISTICS IOgroups the counters for all I/O to a given table together. With this DMV you will get separate counters for every node in the query plan that performs I/O to the table.
If there is a parallel scan, this DMV reports counters for each of the parallel threads working on the scan.
Starting with SQL Server 2016 (13.x) SP1, the standard query execution statistics profiling infrastructure exists side-by-side with a lightweight query execution statistics profiling infrastructure.
SET STATISTICS XML ON and
SET STATISTICS PROFILE ON always use the standard query execution statistics profiling infrastructure. For
sys.dm_exec_query_profiles to be populated, one of the query profiling infrastructures must be enabled. For more information, see Query Profiling Infrastructure.
The query under investigation has to start after the query profiling infrastructure has been enabled, enabling it after the query started will not produce results in
sys.dm_exec_query_profiles. For more information on how to enable the query profiling infrastructures, see Query Profiling Infrastructure.
- On SQL Server and Azure SQL Managed Instance, requires
VIEW DATABASE STATEpermission and membership of the
- On Azure SQL Database Premium Tiers, requires the
VIEW DATABASE STATEpermission in the database.
- On Azure SQL Database Basic, S0, and S1 service objectives, and for databases in elastic pools, the server admin account or the Microsoft Entra admin account is required. On all other SQL Database service objectives, the
VIEW DATABASE STATEpermission is required in the database.
Permissions for SQL Server 2022 and later
Requires VIEW DATABASE PERFORMANCE STATE permission on the database.
Step 1: Login to a session in which you plan to run the query you will analyze with
sys.dm_exec_query_profiles. To configure the query for profiling use
SET STATISTICS PROFILE ON. Run your query in this same session.
--Configure query for profiling with sys.dm_exec_query_profiles
SET STATISTICS PROFILE ON;
--Or enable query profiling globally under SQL Server 2016 SP1 or above (not needed in SQL Server 2019)
DBCC TRACEON (7412, -1);
--Next, run your query in this session, or in any other session if query profiling has been enabled globally
Step 2: Login to a second session that is different from the session in which your query is running.
The following statement summarizes the progress made by the query currently running in session 54. To do this, it calculates the total number of output rows from all threads for each node, and compares it to the estimated number of output rows for that node.
--Run this in a different session than the session in which your query is running.
--Note that you may need to change session id 54 below with the session id you want to monitor.
SELECT node_id,physical_operator_name, SUM(row_count) row_count,
SUM(estimate_row_count) AS estimate_row_count,
CAST(SUM(row_count)*100 AS float)/SUM(estimate_row_count)
GROUP BY node_id,physical_operator_name
ORDER BY node_id;