Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 6.97 KB

File metadata and controls

83 lines (60 loc) · 6.97 KB
title Live Query Statistics | Microsoft Docs
ms.custom
ms.date 10/28/2015
ms.prod sql
ms.reviewer
ms.suite sql
ms.technology performance
ms.tgt_pltfrm
ms.topic conceptual
helpviewer_keywords
query statistics [SQL Server] live query stats
live query statistics
debugging [SQL Server], live query stats
statistics [SQL Server], live query statistics
ms.assetid 07f8f594-75b4-4591-8c29-d63811d7753e
caps.latest.revision 16
author MikeRayMSFT
ms.author mikeray
manager craigg

Live Query Statistics

[!INCLUDEappliesto-ss-xxxx-xxxx-xxx-md] [!INCLUDEssManStudioFull] 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 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 beginning with [!INCLUDEssSQL15] [!INCLUDEssManStudio], however it can work with [!INCLUDEssSQL14].

Applies to: [!INCLUDEssNoVersion] ([!INCLUDEssSQL14] through [!INCLUDEssCurrent]).

Warning

This feature is primarily intended for troubleshooting purposes. Using this feature can moderately slow the overall query performance. This feature can be used with the Transact-SQL Debugger.

To view live query statistics

  1. To view the live query execution plan, on the tools menu click the Live Query Statistics icon.

    Live Query Stats button on toolbar

    You can also view access the live query execution plan by right-clicking on a selected query in [!INCLUDEssManStudio] and then click Include Live Query Statistics.

    Live Query Stats button on popup menu

  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.

    Live Query Stats button in showplan

The live execution plan can also be accessed from the Activity Monitor by right-clicking on the queries in the Active Expensive Queries table.

Live Query Stats button in Activity Monitor

Remarks

The statistics profile infrastructure must be enabled before live query statistics can capture information about the progress of queries. Specifying Include Live Query Statistics in [!INCLUDEssManStudio] enables the statistics infrastructure for the current query session.

Until [!INCLUDEssSQL15], there are two other ways to enable the statistics infrastructure, which can be used to view the live query statistics from other sessions (such as from Activity Monitor):

  • Execute SET STATISTICS XML ON; or SET STATISTICS PROFILE ON; in the target session.

or

Starting with [!INCLUDEssSQL15] SP1, [!INCLUDEssNoVersion] includes a lightweight version of the statistics profile infrastructure. There are two ways to enable the lightweight statistics infrastructure, which can be used to view the live query statistics from other sessions (such as from Activity Monitor):

  • Use global trace flag 7412.

or

Note

Natively compiled stored procedures are not supported.

Permissions

Requires the database level SHOWPLAN permission to populate the Live Query Statistics results page, the server level VIEW SERVER STATE permission to see the live statistics, and requires any permissions necessary to execute the query.

See Also

Monitor and Tune for Performance
Performance Monitoring and Tuning Tools
Open Activity Monitor (SQL Server Management Studio)
Activity Monitor
Monitoring Performance By Using the Query Store
sys.dm_exec_query_statistics_xml
sys.dm_exec_query_profiles
Trace flags
Showplan Logical and Physical Operators Reference