SQL Flow Field Guide

Query hints

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

statement-wide optimizer and execution constraints in OPTION (...)

What changes

Input
none
Output or change
none

Syntax at a glance

<query_hint> ::= { { HASH | ORDER } GROUP | { CONCAT | HASH | MERGE } UNION | { LOOP | MERGE | HASH } JOIN | DISABLE_OPTIMIZED_PLAN_FORCING | EXPAND VIEWS | FAST <integer_value> | FORCE ORDER | { FORCE | DISABLE } EXTERNALPUSHDOWN | { FORCE | DISABLE } SCALEOUTEXECUTION | IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX | KEEP PLAN | KEEPFIXED PLAN | MAX_GRANT_PERCENT = <numeric_value> | MIN_GRANT_PERCENT = <numeric_value> ...

Work example

A measured plan issue may call for a statement-level query hint after normal tuning is complete.

Compare the unhinted plan with one hint in a test copy. Check compile time, reads, and several parameter values.

Check your work Query hints. The plan change solves the measured issue without making common parameter values slower.

Open Microsoft Learn for full syntax, permissions, and details for your version.