Commit 8a0ff5d
sp_BlitzCache: speed up @SlowlySearchPlansFor by skipping the XML cast
Switch the @SlowlySearchPlansFor predicate from
CAST(qp.query_plan AS NVARCHAR(MAX)) LIKE ... to tqp.query_plan LIKE ...,
where tqp comes from sys.dm_exec_text_query_plan. That DMV returns the
plan as NVARCHAR(MAX) directly, so we skip the per-row XML-to-string
cast that dominated the search cost.
The extra CROSS APPLY is only added when @SlowlySearchPlansFor is set,
so non-search runs pay nothing. The existing qp (XML) apply stays in
place because the rest of sp_BlitzCache still needs it for .exist() /
.value() shredding and for @Noobsaibot.
Fixes BrentOzarULTD#3936.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 324ec1d commit 8a0ff5d
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2129 | 2129 | | |
2130 | 2130 | | |
2131 | 2131 | | |
2132 | | - | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
2133 | 2136 | | |
2134 | 2137 | | |
2135 | 2138 | | |
| |||
2183 | 2186 | | |
2184 | 2187 | | |
2185 | 2188 | | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
2186 | 2196 | | |
2187 | 2197 | | |
2188 | 2198 | | |
| |||
0 commit comments