Using the USE PLAN Query Hint
The USE PLAN
query hint in SQL Server 2012 can be used to encourage the Query Optimizer to use the specified XML query plan for processing the query. This option provides more control over influencing the execution of a query than is possible with the other available query hints, such as FORCE ORDER
, LOOP JOIN
, and KEEP PLAN
. None of these options individually are powerful enough to influence the Query Optimizer to consistently choose a particular query plan, especially when the referenced table row counts, statistics, indexes, and other attributes of the environment change.
The USE PLAN
query hint is specified in the OPTION
clause, and you provide it with a query plan in XML format. Listing 31.7 provides an example ...
Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.