{"id":14491,"date":"2015-12-16T10:00:00","date_gmt":"2015-12-16T18:00:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/dataplatforminsider\/2015\/12\/16\/tuning-workload-performance-with-query-store\/"},"modified":"2024-01-22T22:52:26","modified_gmt":"2024-01-23T06:52:26","slug":"tuning-workload-performance-with-query-store","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2015\/12\/16\/tuning-workload-performance-with-query-store\/","title":{"rendered":"Tuning Workload Performance with Query Store"},"content":{"rendered":"
As your database grows, it is not unusual to experience performance problems caused by queries that once performed well, but now perform poorly. Without the ability to see all the changes in the query execution over time, it is difficult to figure out why regressions happen and what you can do to prevent them. Troubleshooting these performance issues can take hours or even days.<\/p>\n
That\u2019s exactly what Query Store, a new feature available in Azure SQL Database<\/a> and SQL Server 2016<\/a>, aims to improve.<\/p>\n Similar to an airplane\u2019s flight data recorder, Query Store constantly collects information about all queries and greatly simplifies performance forensics by reducing the time to diagnose and resolve issues. Query Store also allows you to force query plans from the history, which makes the process of fixing problems with plan choice regressions extremely easy.<\/p>\n As a result, time to detect and mitigate performance issues is now in the range of minutes.<\/p>\n Query Store can be used in a wide set of scenarios when tracking and ensuring predictable workload performance is critical. It is equally useful when you need to react<\/strong> to an immediate problem as well as when you want to ensure optimal performance proactively<\/strong> for the long term (after the database upgrade, for other maintenance operations, or upon new application roll-out, for example).<\/p>\n The following diagram depicts typical usage scenarios from the perspective of proactive\/reactive mode of operation:<\/p>\n Here is a brief scenario description:<\/p>\n For more details, refer to Query Store Usage Scenarios<\/a> on MSDN.<\/p>\n Query Store is a database-scoped feature, so you must first enable it for the databases that you want to monitor. You can enable Query Store very easily from the new UI in SQL Server Management Studio (SSMS) or by running a simple Transact-SQL script:<\/p>\n ALTER DATABASE <database_name><\/span> SET QUERY_STORE = ON;<\/span><\/p>\n Once you have enabled the Query Store, the next thing to do is to analyze the data and tune \u201cproblematic\u201d queries. It will take some time until Query Store collects the data set that accurately represents your workload. Usually, one day is enough even for very complex workloads, but you should adjust the time based on execution patterns in your application. Even so, you can start exploring the data and identifying the queries that need your attention immediately after enabling the feature.
<\/p>\nTypical usage scenarios<\/h1>\n
<\/p>\n\n
\n
Getting started with the Query Store<\/h1>\n
<\/a><\/p>\n
\nThe easiest way to analyze the data is by using a set of built-in views available in the latest SQL Server Management Studio. Navigate to the Query Store sub-folder under the database node in Object Explorer of Management Studio to open troubleshooting views for specific scenarios:<\/p>\n