This update adds a new USE HINT query hint argument, QUERY_PLAN_PROFILE. This argument enables lightweight profiling for the query. When a query that contains this new hint finishes, a new Extended Event, query_plan_profile, is fired. This extended event exposes execution statistics and actual execution plan XML similar to the query_post_execution_showplan extended event but only for queries that contains the new hint.
- When lightweight profiling is enabled for a query, this makes information available for you to analyze runtime performance statistics for the query. Also, you can use features such as sys.dm_exec_query_profiles, sys.dm_exec_query_statistics_xml, and Live Query Statistics.
- If you enable collecting the query_post_execution_showplan extended event, this will add standard profiling infrastructure to every query that is running on the server and therefore may affect overall server performance. If you enable the collecting query_thread_profile extended event to use lightweight profiling infrastructure instead, this will result in much less performance overhead but will still affect overall server performance. If you enable the query_plan_profile extended event, this will only enable the lightweight profiling infrastructure for a query that executed with the QUERY_PLAN_PROFILE and therefore will not affect other workloads on the server. Use this hint to profile a specific query without affecting other parts of the server workload.
For more information about standard and lightweight query profiling, see the sys.dm_exec_query_statistics_xml topic on the Microsoft Docs website.