Why a Query Store forced plan can silently stop being used, how to detect forcing failures, and how to manage forced plans over time.
Forcing only works while the optimiser can still produce that plan. If an index it uses is dropped or renamed, the query text or SET options change (so it is a different query_id), or a schema change makes the plan invalid, forcing fails and SQL Server quietly compiles a normal plan. I notice through force_failure_count and last_force_failure_reason_desc in sys.query_store_plan, the query_store_plan_forcing_failed extended event, or a new plan_id appearing for the query. I also keep Query Store healthy (READ_WRITE, not full) and review forced plans after releases, because plans and data evolve.
How forcing works. When a plan is forced in Query Store, the optimiser still compiles the query, but it is constrained to produce the forced plan's shape. If it can't, the force fails and SQL Server uses whatever plan it compiles normally — the query does not error.
Why it stops working.
NO_INDEX), or a referenced object changed.NO_PLAN), e.g. a computed column or constraint the plan relied on.query_id, which is the query text hash plus context settings. A whitespace change in an ORM-generated query, a different SET ANSI_NULLS / ARITHABORT (SSMS vs ADO.NET defaults), or a new parameter list gives a new query_id with no force on it. That's not a failure — it just isn't the same query any more.MAX_STORAGE_SIZE_MB, existing forcing still applies, but new data stops being captured, so you lose visibility of regressions and failures.How I notice.
sys.query_store_plan: is_forced_plan = 1 with force_failure_count > 0 and last_force_failure_reason_desc (e.g. NO_INDEX, NO_PLAN, GENERAL_FAILURE).query_store_plan_forcing_failed extended event for alerting.plan_id collecting executions for the query.sys.query_store_query_text for the new text and compare context_settings_id.Production example. We forced a seek plan to fix a parameter-sniffing regression. A later migration renamed the index to match a naming convention; the force failed with NO_INDEX, the scan plan came back, and p95 went from 30 ms to 2 s. A scheduled check on force_failure_count caught it the next morning; we re-forced and, more importantly, fixed the underlying sniffing with a better index so the force could be removed.
Checks operational maturity with Query Store: does the candidate know forcing can fail silently and how to watch it?
Green flags: knows forcing is best-effort; lists index changes, schema changes, SET options and query text; uses force_failure_count / last_force_failure_reason_desc and the extended event; mentions Query Store health and reviewing forces.
Red flags: thinks a forced plan is guaranteed forever; doesn't know what makes a query_id; no monitoring; uses forcing instead of fixing the cause.
query_id and context settings. Query Store identifies a query by query_hash of the normalised text, the batch it belongs to (batch_sql_handle for ad hoc, or object_id for a module), and context_settings_id (SET options, language, date format). Change any of these and you get a new query_id. This is why a fix forced while testing in SSMS (ARITHABORT ON) may not apply to the application (ADO.NET uses ARITHABORT OFF).
Morally equivalent plans. The forced plan doesn't need to be byte-identical; SQL Server accepts a morally equivalent plan (same operators and shape). That's why some changes don't break forcing but an index rename does.
Query Store hints (SQL Server 2022, Azure SQL). sys.sp_query_store_set_hints applies hints such as OPTION (RECOMPILE) or MAXDOP to a query_id without code changes. They have the same identity rule and their own failure tracking in sys.query_store_query_hints.
Health. Watch actual_state_desc vs desired_state_desc in sys.database_query_store_options, readonly_reason, and storage. Size-based cleanup (SIZE_BASED_CLEANUP_MODE = AUTO) and a sensible QUERY_CAPTURE_MODE = AUTO keep it in READ_WRITE.
Automatic tuning. FORCE_LAST_GOOD_PLAN forces the previous plan when it detects a regression and un-forces if the forced plan is worse or fails — useful, but you still need to see what it did (sys.dm_db_tuning_recommendations).
-- Forced plans that are failing
SELECT q.query_id,
p.plan_id,
p.force_failure_count,
p.last_force_failure_reason_desc,
p.last_execution_time,
qt.query_sql_text
FROM sys.query_store_plan AS p
JOIN sys.query_store_query AS q ON q.query_id = p.query_id
JOIN sys.query_store_query_text AS qt ON qt.query_text_id = q.query_text_id
WHERE p.is_forced_plan = 1
AND p.force_failure_count > 0;
-- Query Store health
SELECT actual_state_desc, desired_state_desc, readonly_reason,
current_storage_size_mb, max_storage_size_mb
FROM sys.database_query_store_options;
-- Extended event for alerting
CREATE EVENT SESSION QsForcingFailed ON DATABASE
ADD EVENT qds.query_store_plan_forcing_failed
ADD TARGET package0.ring_buffer;
ALTER EVENT SESSION QsForcingFailed ON DATABASE STATE = START;
-- Force / unforce
EXEC sys.sp_query_store_force_plan @query_id = 42, @plan_id = 7;
EXEC sys.sp_query_store_unforce_plan @query_id = 42, @plan_id = 7;
query_id.Plan forcing is a tourniquet. It buys time during an incident, but every forced plan is hidden coupling between the database's physical design and a specific query's text. I keep a short list of forced plans with an owner and a reason, check them in the release pipeline (a migration that drops or renames an index used by a forced plan should fail review), alert on forcing failures, and aim to remove each force once the root cause — sniffing, stale statistics, a missing index — is fixed. With ORMs like EF Core, small LINQ changes alter the SQL text, so a force is more fragile than in a stored procedure.
Last updated 23 Nov 2026.