Query performance is a very important area of SQL server. We always have badly performance queries around.
Query store is the newest tool for tracking and resolving performance problems in SQL server.
In this article, we are going to have a look at some practical uses of SQL server Query store.
What is Query Store?
The query store has been described by Microsoft as a ‘flight data recorder’ for SQL server queries. It tracks the queries run against the database, recording the details of the queries and their plans and their runtime characteristics. Query store is per database feature and runs automatically. Once turned on, nothing further needs to be done to get it to track data. It runs in the background collecting data and storing it for later analysis.
Query store is available in SQL Server 2016 and later, and Azure SQLDB v12 and later. It is available in all editions of SQL server, even in Express edition.
How is Query store different from other tracking options?
We have had query performance tracking for some time though in the form of dynamic management views. Mostly, sys.dm_exec_query_stats and sys.dm_exec_query_plan and tracing tools like SQL server profiler and extended events.
So, what makes Query Store different? Let me start answering that by describing a scenario that I encountered a couple of years ago.
A particular critical system was suddenly performing badly. It had been fine the previous week and there have been no extended events sessions or profiler traces running historically. The admin had restarted the server when the performance problem started, just to make sure it was not something related to a pending reboot.
As such, there was no historical performance data at all and solving the problem of what happened, why the query performance is different this week was extremely difficult.