QUERY_STORE
Query Store: per-database history of query plans and runtime statistics.
- Padrão
ON (READ_WRITE)- Range
- OFF, READ_ONLY, READ_WRITE, with MAX_STORAGE_SIZE_MB, QUERY_CAPTURE_MODE and other options
- Restart needed
- Não
- Default checked on
- SQL Server 2025
O que faz
Records plans and execution statistics in the database, survives restarts, and lets you force a known-good plan. Turned on by default for new databases from SQL Server 2022, with a 1000MB size limit and AUTO capture.
Valor padrão
ON (READ_WRITE). ON for databases created on SQL Server 2022 and later (and in Azure SQL Database); OFF for databases created on older versions. New databases on SQL Server 2025 report READ_WRITE, 1000MB, capture mode AUTO.
Check the current value
SELECT actual_state_desc, max_storage_size_mb, current_storage_size_mb, query_capture_mode_desc FROM sys.database_query_store_options; -- current database
Change it
ALTER DATABASE CURRENT SET QUERY_STORE = ON
(OPERATION_MODE = READ_WRITE, MAX_STORAGE_SIZE_MB = 2048, QUERY_CAPTURE_MODE = AUTO);
No restart; takes effect immediately.
When to change it
Turn it on in user databases created before SQL Server 2022, which keep it off after an upgrade; raise MAX_STORAGE_SIZE_MB if actual_state_desc flips to READ_ONLY because it is full.
What can go wrong
Some write overhead; CAPTURE_MODE = ALL on ad hoc workloads fills it fast.
The closest setting on other engines
| Motor | Configuração | Padrão | Restart |
|---|---|---|---|
| SQL Server |
QUERY_STORE this page
|
ON (READ_WRITE) |
Não |
| PostgreSQL |
log_min_duration_statement
|
-1 (disabled) |
Não |
| MySQL |
long_query_time
|
10 |
Não |
Questions about QUERY_STORE
What is the default value of QUERY_STORE in SQL Server?
ON (READ_WRITE). ON for databases created on SQL Server 2022 and later (and in Azure SQL Database); OFF for databases created on older versions. New databases on SQL Server 2025 report READ_WRITE, 1000MB, capture mode AUTO.
Does changing QUERY_STORE require a restart?
No. No restart; takes effect immediately.
When should I change QUERY_STORE?
Turn it on in user databases created before SQL Server 2022, which keep it off after an upgrade; raise MAX_STORAGE_SIZE_MB if actual_state_desc flips to READ_ONLY because it is full.
Back to all SQL Server settings, or check the SQL Server manual for every option.
Related on SQLly
Check QUERY_STORE on your own server
SQLly runs the query above against SQL Server and the other engines in this reference, from one desktop app on macOS, Windows and Linux.