The SET FORCEPLAN
statement overrides the logic used by the SQL Server query optimizer to process a T-SQL SELECT
statement.
More specifically, when FORCEPLAN
is set to ON
, the query optimizer processes a join in the same order as the tables appear in the FROM
clause of a query.
This also forces the use of a nested loop join unless other types of joins are required to construct a plan for the query, or they are requested with join hints or query hints.
Continue reading