{"id":44012,"date":"2022-08-18T08:00:00","date_gmt":"2022-08-18T15:00:00","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/?p=44012"},"modified":"2024-04-19T10:39:24","modified_gmt":"2024-04-19T17:39:24","slug":"query-store-is-enabled-by-default-in-sql-server-2022","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2022\/08\/18\/query-store-is-enabled-by-default-in-sql-server-2022\/","title":{"rendered":"Query Store is enabled by default in SQL Server 2022"},"content":{"rendered":"\n

Part of the SQL Server 2022 blog series<\/a>.<\/em><\/p>\n\n\n\n

Query Store<\/a> is one of the most powerful database-scoped features in SQL Server for troubleshooting performance and improving the stability of your database workloads.<\/p>\n\n\n\n

The Query Store feature first became available in SQL Server 2016 and provides the ability for database administrators (DBAs) to gain insights on query plan choice and the impact these choices have on SQL Server performance.<\/p>\n\n\n\n

In SQL Server 2022<\/a>, Query Store is now enabled by default for all newly created SQL Server databases to help customers better track performance history, troubleshoot query plan\u2013related issues, and enable new query processor capabilities that we will introduce in the subsequent SQL Server 2022 blog series<\/a>.<\/p>\n\n\n\n

When enabled, Query Store asynchronously captures a history of queries, plans, and runtime statistics, and persists this data at the database scope. This means that when you migrate your databases to another version of SQL Server, migrate to different hardware, or even migrate your databases to the cloud\u2014you can examine the performance difference down to the query plan level.<\/p>\n\n\n\n

Query Store accomplishes this by separating the performance data by time windows so DBAs can identify usage patterns and understand when query plan changes happened on the server.<\/p>\n\n\n\n

If an application starts having a performance issue which can occur in a number of scenarios such as high usage, post-migration, and especially when data distributions change\u2014Query Store provides a method to force which plan a query will use<\/a>. The ability to control which plans a query will use makes it much easier to respond to errant query plans and provides database administrators with the assurance they can upgrade to later versions of SQL Server, change database compatibility levels, and confidently migrate database applications to the cloud.  <\/p>\n\n\n\n

For all these scenarios, Query Store gives DBAs the confidence that they can easily monitor their database application\u2019s performance and quickly respond to performance issues when needed.<\/p>\n\n\n\n

Query Store is available for SQL Server, Azure SQL Database, Azure SQL Managed Instance, and Azure Synapse Analytics. In Azure SQL database, Query Store is referred to as Query Performance Insights<\/a> and is managed on the Query Performance Insight navigation blade.<\/p>\n\n\n\n

Query Performance Insights in Azure SQL Database<\/h2>\n\n\n\n

While it is a new scenario to have Query Store enabled by default for SQL Server, Query Store has be enabled by default for Azure SQL Database<\/a> (including elastic pools<\/a>) and Azure SQL Managed Instance<\/a> databases for some time now and this capability has been extended to SQL Server 2022.<\/p>\n\n\n\n

Query Store has been a popular feature since it was first made available in SQL Server 2016, and now in SQL Server 2022 we are leveraging Query Store\u2019s ability to persist query plan history and health to enable new capabilities.<\/p>\n\n\n\n

Query Store in SQL Server 2022 extends the ability of the query processor by enabling features such as Query Store hints, cardinality estimation (CE) feedback, degree of parallelism (DOP) feedback, memory grant feedback (MGF) persistence, and optimized plan forcing.<\/p>\n\n\n\n

Query Store\u2019s ability to asynchronously make a record of your database application\u2019s performance data enables these new capabilities in SQL Server 2022.<\/p>\n\n\n\n

While we are enabling Query Store by default for all newly created databases in SQL Server 2022, it is important to note that for all databases that have been restored from other SQL Server instances and for those databases that are upgraded from an in-place upgrade to SQL Server 2022, these databases will retain the previous Query Store settings\u2014whether they had Query Store enabled or not.<\/p>\n\n\n\n

As a post-migration step, for databases that are restored from previous SQL Server instances, it is recommended to enable Query Store<\/a> and separately evaluate the database compatibility level<\/a> settings as some Intelligent Query Processing features<\/a> are enabled by the compatibility level setting.<\/p>\n\n\n\n

Note: <\/strong>For optimal SQL Server performance and migration health, it is recommended to closely follow the recommendations provided in the post-migration validation and optimization guide<\/a>.<\/p>\n\n\n\n

Query Store overhead<\/h2>\n\n\n\n

As mentioned, Query Store has been available in Azure SQL Database and Azure SQL Managed Instance since 2016; additionally, we have improved Query Store performance in the last several releases of SQL Server with many improvements being surfaced through cumulative updates<\/a> in SQL Server 2019.<\/p>\n\n\n\n

Query Store improvements introduced via cumulative updates<\/h3>\n\n\n\n

Microsoft has improved ad-hoc workloads with Query Store with several cumulative updates in SQL Server 2019.<\/p>\n\n\n\n

The most relevant cumulative updates that influence Query Store health are:<\/p>\n\n\n\n