Skip to content

Commit 50d10f5

Browse files
Remove pointless WAITFOR DECOMPRESS filters from stats/store queries
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>
1 parent a88572c commit 50d10f5

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

Dashboard/Services/DatabaseService.QueryPerformance.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,6 @@ FROM collect.query_stats AS qs
11041104
OR (qs.last_execution_time >= @fromDate AND qs.last_execution_time <= @toDate)
11051105
OR (qs.creation_time <= @fromDate AND qs.last_execution_time >= @toDate)))
11061106
)
1107-
AND CAST(DECOMPRESS(qs.query_text) AS nvarchar(max)) NOT LIKE N'WAITFOR%'
11081107
GROUP BY
11091108
qs.database_name,
11101109
qs.query_hash,
@@ -1477,7 +1476,7 @@ USE HINT('ENABLE_PARALLEL_PLAN_PREFERENCE')
14771476
ISNULL(SUM(qsd.avg_physical_io_reads * qsd.count_executions), 0) AS total_physical_reads,
14781477
ISNULL(SUM(qsd.avg_logical_io_writes * qsd.count_executions), 0) AS total_writes
14791478
FROM collect.query_store_data AS qsd
1480-
WHERE CAST(DECOMPRESS(qsd.query_sql_text) AS nvarchar(max)) NOT LIKE N'WAITFOR%'
1479+
WHERE 1 = 1
14811480
{timeFilter}
14821481
GROUP BY DATEADD(HOUR, DATEDIFF(HOUR, 0, qsd.collection_time), 0)
14831482
ORDER BY bucket_hour;";
@@ -1580,7 +1579,6 @@ FROM collect.query_store_data AS qsd
15801579
OR (qsd.server_last_execution_time >= @fromDate AND qsd.server_last_execution_time <= @toDate)
15811580
OR (qsd.server_first_execution_time <= @fromDate AND qsd.server_last_execution_time >= @toDate)))
15821581
)
1583-
AND CAST(DECOMPRESS(qsd.query_sql_text) AS nvarchar(max)) NOT LIKE N'WAITFOR%'
15841582
GROUP BY
15851583
qsd.database_name,
15861584
qsd.query_id

0 commit comments

Comments
 (0)