Skip to content

Comments

Fix query/procedure stats collectors ignoring recent queries#242

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/query-stats-time-filter
Feb 23, 2026
Merged

Fix query/procedure stats collectors ignoring recent queries#242
erikdarlingdata merged 1 commit intodevfrom
feature/query-stats-time-filter

Conversation

@erikdarlingdata
Copy link
Owner

Summary

  • Both query_stats and procedure_stats collectors used TOP N ORDER BY total_elapsed_time DESC with no time filter, so long-running cached plans (e.g. HammerDB TPC-H) permanently occupied all slots and recently-executed queries were never collected
  • Added last_execution_time >= DATEADD(MINUTE, -10, GETDATE()) filter to both collectors (all query variants including Azure SQL DB)
  • Bumped query_stats TOP from 50 to 200 to capture more active queries per sweep

Test plan

  • Verified fixed SQL runs clean on SQL2022 — returns only recently-executed queries
  • Verified HammerDB queries (last executed 8+ hours ago) are correctly excluded
  • Verified new queries show up immediately after execution
  • Lite builds with 0 errors

🤖 Generated with Claude Code

Both collectors used TOP N ORDER BY total_elapsed_time DESC with no
time filter, so long-running cached plans (e.g. HammerDB) permanently
occupied all slots and recently-executed queries were never collected.

Added last_execution_time >= DATEADD(MINUTE, -10, GETDATE()) filter to
both collectors (all query variants including Azure SQL DB). Bumped
query_stats TOP from 50 to 200 to capture more active queries per sweep.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 20bb01e into dev Feb 23, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/query-stats-time-filter branch February 23, 2026 21:07
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