Remove WAITFOR DECOMPRESS filters from query stats and query store#853
Merged
erikdarlingdata merged 2 commits intodevfrom Apr 16, 2026
Merged
Remove WAITFOR DECOMPRESS filters from query stats and query store#853erikdarlingdata merged 2 commits intodevfrom
erikdarlingdata merged 2 commits intodevfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CAST(DECOMPRESS(...)) NOT LIKE N'WAITFOR%'from 3 queries:GetQueryStatsAsync— query_stats grid (the 120-second timeout culprit)GetQueryStoreDataAsync— query store griddm_exec_query_stats/ Query Store data is pointlessNot changed (these are legitimate):
report.query_snapshots) — WAITFOR shows up in active sessionsRelated to #835
Test plan
🤖 Generated with Claude Code