Query Store status


Job details

Name: Query Store status
Platform: Sqlserver
Category: Capacity
Description: Checks Query Store space usage in every database where it is enabled.
Long description: Checks Query Store space usage in every database where it is enabled by analyzing statistic from sys.database query store_options system catalog view.
Version: 1.32
Default schedule: 30 * * *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2014′ & hasengine=‘YES’ & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
ignore databases model List of databases (separated by comma) which will be ignored. You can use % (percent sign) to represent wild card characters.
min histr interval 4 The minimum number of hours before a new history record will be inserted into the history table.
warning threshold 90 The maximum percentage of space usage allowed for Query Store before a warning is triggered.
alarm threshold 95 The maximum percentage of space usage allowed in the Query Store before an alarm is triggered.
history threshold 30 The number of days the statistics are kept in the history table.
return status when READ ONLY 1 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when the Query Store stops (gets in READ ONLY mode)

Job Summary

SELECT actual_state_desc, current_storage_size_mb, max_storage_size_mb, readonly_reason FROM [YourDatabaseName].sys.database_query_store_options;

Task Procedures and Operations

The monitoring job performs several key operations:

Dependency Management

The job has dependencies to ensure data integrity and proper cleanup in failure scenarios:

Object Type Description
dbw_query_store_status_proc Procedure Main procedure checking Query Store status
dbw_query_store_tab Temporary Table Holds the current status of the Query Store
dbw_query_store_histr_tab Temporary Table Holds historical Query Store usage statistics
dbw_query_store_stat Temporary Table Temporary table for ongoing statistics

Reporting and Alerts

Reports generated by the monitoring job provide insights into:

The job defines two essential reports:

Describing these components provides a clear understanding of how the monitoring job functions, the critical dependencies involved, and the significant role of reporting in ongoing database management.