Skip to content

Remove WAITFOR DECOMPRESS filters from query stats and query store#853

Merged
erikdarlingdata merged 2 commits intodevfrom
fix/remove-waitfor-decompress
Apr 16, 2026
Merged

Remove WAITFOR DECOMPRESS filters from query stats and query store#853
erikdarlingdata merged 2 commits intodevfrom
fix/remove-waitfor-decompress

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • Removes CAST(DECOMPRESS(...)) NOT LIKE N'WAITFOR%' from 3 queries:
    • GetQueryStatsAsync — query_stats grid (the 120-second timeout culprit)
    • GetQueryStoreDataAsync — query store grid
    • Query store slicer/trend query
  • WAITFOR has no execution plan and no meaningful stats — filtering it from dm_exec_query_stats / Query Store data is pointless
  • The filter was decompressing every row's query text just to check a prefix — on 742K rows, this was a major contributor to timeouts

Not changed (these are legitimate):

  • Query snapshot filters (report.query_snapshots) — WAITFOR shows up in active sessions
  • MCP phased queries — filter applied after TOP on already-hydrated text, so it's cheap

Related to #835

Test plan

  • Builds with 0 errors
  • Query stats grid loads without timeouts on large installations

🤖 Generated with Claude Code

erikdarlingdata and others added 2 commits April 16, 2026 07:48
The CAST(DECOMPRESS(...)) NOT LIKE N'WAITFOR%' filter was decompressing
query text on every row in query_stats and query_store_data just to skip
WAITFOR queries. WAITFOR has no plan and no meaningful stats — it only
matters in query snapshots (active sessions), where the filter remains.

On a 742K-row query_stats table, this was a significant contributor to
the 120-second query timeouts reported in #835.

The snapshot filters (report.query_snapshots) and MCP phased queries
are untouched — they filter after TOP on already-hydrated text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All three grid queries now use a 3-phase pattern:
1. Aggregate numerics into temp table (no DECOMPRESS)
2. Sum across lifetimes, rank TOP 500
3. OUTER APPLY to decompress text/plan for only the 500 winners

On a 742K-row query_stats table, this reduces DECOMPRESS calls from
742K to 500 — eliminating the 16+ minute query times reported in #835.

Matches the existing phased pattern used by the MCP query tools.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 29e561c into dev Apr 16, 2026
3 checks passed
@erikdarlingdata erikdarlingdata deleted the fix/remove-waitfor-decompress branch April 19, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant