r/SQLServer • u/erinstellato Microsoft Employee • Jun 26 '26
Discussion Friday Feedback: Managing Query Store size
First Friday Feedback about Query Store 🎉
This week I have a poll about whether you'd be interested in having the max size (MAX_STORAGE_SIZE_MB) of Query Store managed for you.
The default size for SQL 2019 and higher and the SQL dbs (Azure and Fabric) is 1GB.
The max size for SQL dbs is 10GB; there is no max for box (but remember, just because you can, doesn't mean you should...)
I used to tell customers start with something like 2GB or 4GB, and monitor from there. But maybe we should figure out the size and manage it for you? Bonus internet points if you add a comment with additional input or reasoning about your response.
6
u/raistlin49 Jun 26 '26
Fun fact from recent lesson learned - if query store fills up and you run an ALTER DATABASE to set MAX_STORAGE_SIZE_MB it will invalidate user queries in the plan cache (not the query store) and force recompiles on all incoming user load, sending CPU to 100%.
3
u/B1zmark 1 Jun 26 '26
CDC goes back a fixed number of hours, but QUERY STORE goes by size.
Realistically, query store should have at least 1 month of stats. That's what i aim for with customers as a minimum, then use a pipeline to store the important stuff for long term analysis like quarter and year end.
1
u/No_Resolution_9252 Jun 27 '26
I voted only for Azure SQL DB - my use of that has mainly been trash apps no one really cared to support or provide priority to support, not a lot of exposure. I would be extremely leery about letting it be managed automatically in more critical environments. I unintentionally set one of mine thinking in kilobytes, to a terabyte and grew to several hundred Gb. It has never really seemed that scientific figuring out what retention and size needs to be configured. ERP systems for instance commonly have irregular massive amounts of adhoc queries that fire off that need to be retained and its a balancing act of getting the number of days high enough to keep them in query store, but not have the query store get too big either
1
u/SonOfZork Jun 27 '26
At scale, enabling query store is a great way to take down your server 😞
1
u/_cess Jun 27 '26
Hi Erin,
Voted on have control, and depending on which option wins, I have a couple of extra feedback/request.
If it's manages by Microsoft, I would like to have a clear understanding what is the max size (I'm assuming that way we can't set one). Why? When troubleshooting something, if I no longer see specific old plan/execution I want to know that happened because I reached the max and the clean up kicked in.
If managed by us (we can still set a max value), we can always have an message remembering that a query store too big can also have its "issues" (and point to an MS Article).
What I would like to have, still in this space, is the ability to control when the housekeeping kicks in. As far as I remember reading from someone blog post (and it seems to match what I saw afterwards in a couple of systems), it seems that it kicks based on the start time of the sql server, if, for whatever reason, that happened during a common pick time, the housekeeping queries can/will appear on the top queries (execution count/io) of that period and can contribute to higher CPU. Ideally, we can set a period and housekeep in a quieter period.
1
u/muaddba 1 Jun 29 '26
IMO this should be an easy toggle setting so that people who don't want to manage it can have it automatically managed. If you've been a DBA for any length of time, you've had one of SQL Server's "automatic" features kick you right in the tenders. I'm not sure why any new feature would be added without a "turn this feature off" setting,