This was an interesting one to narrow down.
When messing about (developing) things that are based on the query store I came across an unusual phenomenon. We were missing query store intervals. It’s not that data had been deleted but rather than it was never created in the first place. Take a look at this;
I’d set the query store to 5 minute intervals for testing purposes and left it. Notice that there is no data between 15:20 and 15:25. It’s not that the data has been deleted, we know that because the runtime_stats_interval_id is still creating increments correctly.
Turns out, that if there is no activity on your user database for any given interval then the Query Store will just decide that it doesn’t need to capture anything at all for that interval.
This makes sense from a Query Store perspective, but, just don’t rely on those intervals being there if you’re joining this data to other performance metrics like I was…