Back to results for “Query Store”
SQL Server › Query Optimization & Plans

How do you use the SQL Server Query Store feature to identify and address query performance regressions over time?

Advanced

Answer

Query Store automatically captures a history of execution plans and their performance metrics over time, letting you compare how a specific query has performed across different plans and time periods, quickly spot when a regression occurred, such as after a deployment, and even force SQL Server to use a previously known good execution plan if the current one has become a performance problem.
ALTER DATABASE MyDatabase SET QUERY_STORE = ON;

-- Later, identify regressed queries
SELECT * FROM sys.query_store_query_text
WHERE query_text_id IN (SELECT query_text_id FROM sys.query_store_query);
Real-world example A team uses Query Store to quickly identify that a specific report's performance regressed right after a recent deployment, and forces SQL Server back to the previously known good execution plan while they investigate the actual root cause.

Common follow-ups: How do you force a specific historical plan using Query Store?;What is the storage overhead of enabling Query Store on a busy database?