How would you configure Query Store's capture and retention settings to balance detailed monitoring with storage overhead on a very busy production database?
Short answer
You would adjust settings such as the maximum size allocated for Query Store data, the data flush interval controlling how often captured information is written to disk, the statistics collection interval controlling the granularity of captured metrics, and the retention period…
Advertisement
AModel answer
You would adjust settings such as the maximum size allocated for Query Store data, the data flush interval controlling how often captured information is written to disk, the statistics collection interval controlling the granularity of captured metrics, and the retention period, tuning these based on how much history you actually need versus the storage and overhead you are willing to accept.
ALTER DATABASE MyDatabase SET QUERY_STORE (
MAX_STORAGE_SIZE_MB = 1000,
INTERVAL_LENGTH_MINUTES = 15,
STALE_QUERY_THRESHOLD_DAYS = 30
);Real-world example
A busy e-commerce platform carefully tunes its Query Store settings, balancing a reasonable thirty day retention period against a defined storage limit, ensuring they have enough history for troubleshooting without letting Query Store data consume excessive disk space.
Likely follow-ups
- What happens when Query Store reaches its configured maximum storage size?
- How do you monitor how much storage Query Store is currently consuming?
Related topics