QUERY HINT OPTIMIZE FOR UNKNOWN
Instructs the Query Optimizer to use the average selectivity of the predicate across all column values, instead of using the runtime parameter value when the query is compiled and optimized.
What changes
- Input
- none
- Output or change
- none
Syntax at a glance
OPTION ( OPTIMIZE FOR UNKNOWN )
Work example
A measured query issue may justify testing QUERY HINT OPTIMIZE FOR UNKNOWN against the optimizer's default choice.
Capture the current plan, rows, reads, and elapsed time. Change one hint in a test copy and compare the same parameter values.
Check your work QUERY HINT OPTIMIZE FOR UNKNOWN. The intended plan behavior for QUERY HINT OPTIMIZE FOR UNKNOWN is visible and the result rows are unchanged across the comparison.
Open Microsoft Learn for full syntax, permissions, and details for your version.