Skip to content

Issue #287: Use database_query_store_options for QS detection#292

Merged
erikdarlingdata merged 1 commit intodevfrom
worktree-issue-287-qs-detection
Feb 25, 2026
Merged

Issue #287: Use database_query_store_options for QS detection#292
erikdarlingdata merged 1 commit intodevfrom
worktree-issue-287-qs-detection

Conversation

@erikdarlingdata
Copy link
Owner

Summary

  • Replace sys.databases.is_query_store_on with sys.database_query_store_options.actual_state > 0 for detecting Query Store-enabled databases
  • Fixes Azure SQL DB issue where is_query_store_on reports 0 when QS is actually enabled
  • Uses EXISTS pattern that handles empty views, NULL, and disabled states cleanly
  • Applied to both Lite collector (RemoteCollectorService.QueryStore.cs) and Dashboard collector (09_collect_query_store.sql)

Closes #287

Test plan

  • Both apps build with 0 errors
  • Tested detection query on sql2022 — returns same database list as old approach
  • EXISTS pattern is null-safe: no rows, actual_state = 0, and actual_state IS NULL all correctly skip the database
  • TRY/CATCH per database handles inaccessible databases gracefully

🤖 Generated with Claude Code

…e_on

sys.databases.is_query_store_on can be out of sync with reality on Azure SQL DB,
reporting 0 when Query Store is actually enabled. Replace the filter with a per-database
check against sys.database_query_store_options.actual_state, which reflects the true
state. The EXISTS pattern handles empty views, NULL, and disabled states cleanly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit c437185 into dev Feb 25, 2026
7 checks passed
@erikdarlingdata erikdarlingdata deleted the worktree-issue-287-qs-detection branch February 25, 2026 20:58
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