Gate Query Store wait stats for SQL 2017+ with capture mode check#142
Merged
erikdarlingdata merged 1 commit intodevfrom Mar 25, 2026
Merged
Gate Query Store wait stats for SQL 2017+ with capture mode check#142erikdarlingdata merged 1 commit intodevfrom
erikdarlingdata merged 1 commit intodevfrom
Conversation
sys.query_store_wait_stats only exists on SQL Server 2017+ (major >= 14) and Azure SQL DB. Additionally, wait stats capture can be disabled per database via WAIT_STATS_CAPTURE_MODE = OFF. Changes: - Add SupportsQueryStoreWaitStats property to ServerMetadata (major >= 14 or Azure) - Add IsWaitStatsCaptureEnabledAsync to QueryStoreService — checks wait_stats_capture_mode_desc in sys.database_query_store_options - Gate QueryStoreGridControl: accept supportsWaitStats flag, hide wait stats panel/column/splitter when unsupported, skip all fetch calls - Wire both checks in QuerySessionControl before constructing the grid On SQL 2016 or when capture is OFF: no wait stats queries are issued, the panel is collapsed, and the Wait Profile column is hidden. 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
sys.query_store_wait_statsonly exists on SQL Server 2017+ and Azure SQL DB. Additionally, wait stats capture can be disabled per database viaWAIT_STATS_CAPTURE_MODE = OFF. Without this gate, the wait stats queries from PR #137 would fail on SQL 2016 or when capture is disabled.Changes:
SupportsQueryStoreWaitStatsproperty toServerMetadata(major version >= 14 or Azure)IsWaitStatsCaptureEnabledAsync()toQueryStoreService— checkswait_stats_capture_mode_descinsys.database_query_store_optionsQueryStoreGridControlaccepts asupportsWaitStatsconstructor parameter — whenfalse, hides the wait stats panel, splitter, chevron, and Wait Profile column_waitStatsSupported && _waitStatsEnabledQuerySessionControlwires both checks (version + capture mode) before constructing the gridBehavior on SQL 2016 or capture OFF: No wait stats queries issued, panel collapsed, column hidden. No errors.
Test plan
WAIT_STATS_CAPTURE_MODE = OFF— wait stats panel hidden🤖 Generated with Claude Code