Query Store Trace Flags

Trace Flag 7745 | Faster Shut Downs

Trace flag 7745 prevents the default behaviour where Query Store writes data to disk before SQL Server can be shut down. This means that Query Store data that has been collected but has yet to be persisted to disk will be lost up to the time window defined with DATA_FLUSH_INTERVAL_SECONDS.

Trace Flag 7752 | Faster Start Ups

Trace flag 7752 enables asynchronous load of Query Store. This allows a database to become online and queries to be executed before the Query Store fully recovers. The default behaviour is to do a synchronous load of Query Store. The default behaviour prevents queries from executing before Query Store has been recovered but also prevents any queries from being missed in the data collection.

Suggested Action

Enabling trace flag 7752 allows queries to execute while Query Store data is loaded asynchronously in the background. However, Query Store will be in a read-only state during this time. Enabling trace flag 7745 can improve the availability of databases by preventing Query Store from writing data to disk before SQL Server can be shut down.

Enable TF7745 & TF7752 on startup using startup parameters.

Further Reading

​SCM Services - Configure Server Startup Options | Microsoft Docs

​DBCC TRACEON - Trace Flags (Transact-SQL) | Microsoft Docs