Sql-server – What could cause problematic queries to disappear from QueryStore

sql server

I have a log table of "Execution Timeout Expired" error messages. The timeouts occurred at a certain time (say 11/17, 1:23 pm). A couple weeks ago, I was able to go into Query Store, "Top Resource Consuming Queries", click on "Configure", go to the Custom time setting, and pick that exact minute where the timeouts occurred. I found 1 procedure and 1 function that were consuming lots of resources – a very clear spike. I can't remember exactly what it was (CPU, Logical reads) but I think it may have been all of them.

And there seemed to be an obvious problem that I could fix (basically the function was in the join clause, and the SP could be re-written to avoid the function).

But now I'm trying to validate this finding, that the specific sp and function were the problem. And when I do, in Query Store, what I believe is the exact same thing I did a few weeks ago, the sp and function doesn't show up at all.

Is there something obvious I'm missing? Could something have been dropped from Query Store? Other stored procedures and functions are still showing up for that time period, just not the ones that showed as spiked when I checked last time.

Best Answer

QueryStore has a variety of settings for configuration but you need to be aware that there is a cleanup job that removes things that are too old or exceed one of the other configuration thresholds - read more about them here:-

https://www.sqlskills.com/blogs/erin/query-store-settings/