Sample Header Ad - 728x90

How to check Query Store settings on model database?

6 votes
1 answer
808 views
Query Store can be enabled on the *model* database and ensures that every new database has the same settings as the *model* database. The GUI option is missing Missing Query store option in GUI But it can be enabled using TSQL ALTER DATABASE model SET QUERY_STORE = ON (OPERATION_MODE = READ_WRITE); Since there is no GUI, I can't check the default settings there. Using TSQL again USE model; select * from sys.database_query_store_options; Returns empty result Empty result from the model database Query Store settings When I create a new database (that uses the model as a template and query the settings, it shows me the result) create database TestQs; go use TestQs; select * from sys.database_query_store_options; Query store options for TestQS database Also, the settings must be saved somewhere because when I change the *Query Store* options, the change is propagated to new databases ALTER DATABASE model SET QUERY_STORE (INTERVAL_LENGTH_MINUTES = 22); I've tried to use SMO to find those options, but no luck. $SqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server -ArgumentList 'localhost' $sqlServer.Databases['TestQs'].QueryStoreOptions Database TestQS returns the options But the same query for the *model* database yields nothing $SqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server -ArgumentList 'localhost' $sqlServer.Databases['model'].QueryStoreOptions Database model returns empty options Is there a way to check *Query Store* settings on the *model* database without creating a new database and checking there?
Asked by Zikato (5724 rep)
Sep 9, 2021, 08:52 AM
Last activity: Sep 9, 2021, 03:53 PM