Anonymous 2148
Hi! Github issue template told me to go wander so here I am. sp_QuickieStore reports 20 executions for query_id / plan_id in the interval. Query Store "tracking query" report shows like somewhere around 80 execs for same query_id / plan_id. Does SP show only the last interval from Query Store (making param @start_date useless in that case)? Where does SP get first and last exec times then?
Top Answer
Hi there!

Thanks for using sp_QuickieStore.

The reason for the discrepancy is likely because the query that executes to get a working set of plans to work on only gets the `TOP (N)` plans with an `execution_type = 0` from `query_store_runtime_stats`. The default is 10. That's the same place that the `@start_date` and `@end_date` parameters are applied as well.

It may help to use a bigger value for the `@top` parameter, since it appears multiple plans are present for the statements and perhaps not all of them make it into the initial data set.

There's also a possibility that a built-in default for the `@plans_top` value -- 1 if `@include_plan_ids` is specified and 10 if not -- may be artificially limiting the plans that make it into the final result. 

Here's what I'd suggest:

1. Try a larger value for the `@top` parameter
2. If that doesn't work, crack open the proc and ctrl+f for `@plans_top`, then change the `case` expression that controls the value to something like:

@plans_top =   
        WHEN @include_plan_ids IS NULL
        THEN 1
        ELSE 9223372036854775807

Let me know how that goes!

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.