Commit ffb813b
sp_BlitzCache: reuse #plan_cache_by_db for NumberOfPlans aggregation
The UPDATE that sets NumberOfPlans / NumberOfDistinctPlans / plan_multiple_plans
was rescanning sys.dm_exec_query_stats + sys.dm_exec_plan_attributes, even
though #plan_cache_by_db already holds database_id, query_hash, and
query_plan_hash from the earlier scan. Aggregate out of the temp table
instead and save a second full pass over the plan cache (and a
plan_attributes call per plan_handle) on every default call.
Fixes BrentOzarULTD#3939.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 4d0c812 commit ffb813b
1 file changed
Lines changed: 16 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3155 | 3155 | | |
3156 | 3156 | | |
3157 | 3157 | | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
3158 | 3162 | | |
3159 | 3163 | | |
3160 | 3164 | | |
3161 | 3165 | | |
3162 | 3166 | | |
3163 | 3167 | | |
3164 | | - | |
3165 | | - | |
3166 | | - | |
3167 | | - | |
3168 | | - | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
3169 | 3173 | | |
3170 | | - | |
3171 | | - | |
3172 | | - | |
3173 | | - | |
3174 | | - | |
3175 | | - | |
3176 | | - | |
3177 | | - | |
3178 | | - | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
3179 | 3181 | | |
3180 | 3182 | | |
3181 | 3183 | | |
| |||
0 commit comments