The sys.dm_exec_query_statistics_xml DMF

SQL Server 2016 SP1 introduced a new DMF named sys.dm_exec_query_statistics_xml, which leverages LWP by default, but it also works if Standard Profiling is enabled. This DMF outputs the query execution plan as a snapshot of the current in-flight request. As such, this query execution plan will have transient runtime statistics captured at the moment the DMF was invoked.

The ability to programmatically access the query execution plan for any running request is a leap forward for scenarios in which we must troubleshoot a long-running query. In this case, we can use this DMF, or LQS, which we discussed in the first section of this chapter.

Let's look at a practical example of using this new DMF. The following ...

Get Learn T-SQL Querying now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.