# The Query Store: Intelligent Query Memory
> [!Note]
> The **Query Store** provides a persistent, workload-aware repository of queries, plans, and execution statistics—enabling you to monitor performance trends, detect plan regressions, and apply targeted optimizations without disrupting live workloads.
Introduced in SQL Server 2016, the Query Store automatically captures each query’s text, its execution plans, and related runtime metrics into a dedicated internal store. By persisting this information, it transforms transient execution data into a rich historical record that you can query via catalog views or inspect in SSMS.
> [!tip]
> Enable the Query Store on your busiest databases to gain immediate visibility into plan stability and performance drift over time.
Configuration is straightforward—options for **data retention**, **cleanup policies**, and **capture modes** (all queries versus high-cost only) are exposed both in the UI and through T-SQL. Its lightweight design ensures minimal impact on ongoing operations, while built-in diagnostics help you pinpoint regressions caused by plan changes.
> [!info]
> Use the Query Store’s plan forcing feature to lock in a known-good plan when automatic plan selection yields suboptimal performance.
With SQL Server 2022, new capabilities such as **intelligent query processing integration**, **Query Store hints**, and support for **secondary replicas** further streamline performance tuning in high-availability environments. These enhancements let you offload monitoring to read-only replicas and embed guidance directly into queries.
> [!warning]
> Monitor the size of the Query Store and adjust its **max storage size**; unchecked growth can lead to write bottlenecks if heavy ad hoc workloads populate the store.
By leveraging the Query Store, you can proactively detect **performance regressions**, compare plan histories side by side, and implement targeted fixes—whether through plan forcing, index recommendations, or query hints—while preserving uninterrupted service.
---
## ## References
- Korotkevitch, D. (2022). _SQL Server advanced troubleshooting and performance tuning: Best practices and techniques_. O’Reilly Media.
- Nevarez, B. (2022). _SQL Server query tuning and optimization: Optimize Microsoft SQL Server 2022 queries and applications_. Packt Publishing.