In this article we will introduce you to the query store feature present in Ms SQL Server
SQL Server 2016 has come up with a jazzed up feature to store queries. The Query Store feature in SQL Server not only keeps a record of recently executed queries, query execution plans, query runtime execution statistics but also stores them for troubleshooting performance problems due to query plan changes. The feature allows the user to receive insights on query and complete performance of the database. The user has to activate the feature to make things easy. It is a blessing for all the DBAs struggling with performance troubleshooting.
The Query Store feature can help a DBA in performance troubleshooting in the following ways:
- The feature is integrated along with SQL Server engine and contains all the gathered information inside database tables for future purposes. This allows the user to get data even after server restart or upgrade.
- It consists of multiple Dynamic Management Views (DMVs) for accessing gathered information and pre-built reports for quick analysis of the gathered information.
- The DBA can activate the feature for all those databases for which they want to troubleshoot performance.
When to use Query Store
- It can be used when there is a requirement to gather query text and query execution plan, for comprehending the workload used by users and customers.
- To ascertain how many times a query was executed in a set time frame.
- To fix queries with regressed performance after execution plan changes or any recent updates
How to retrieve gathered data in Query Store
After being activated, the feature begins collecting query texts executed for a particular database, and the execution plans along with query execution statistics are collected at the time of actual query execution. While compiling a query, SQL Server collects query text and query execution plan to save it in- memory first. Similarly after each execution, runtime execution statistics are collected, combined and saved in-memory. With time the in-memory data is passed on to the disk either on a scheduled time or during memory pressure.
The feature combines information on the basis of the specified time granularity, and the combined information is stored on disk through background processes asynchronously. During memory pressure on server, data will be passed on to the disk to free space for others. While querying data in Query Store using DMV or Table Valued Functions, data will be merged from memory and disk transparently to grant access to complete details.
This feature considerably simplifies the task of troubleshooting problems for a DBA. Further it also maintains a record of recently performed queries and execution plans along with storing runtime statistics. The feature needs to be manually activated and then automatically begins all operations; the feature also helps in retaining query data after an update or restart. This article also threw light on where should you use Query Store feature along with retrieval options.
The SQL Server 2016 is a fantastic piece of software and yet it is still susceptible to SQL crashes
When we evaluate the commercial database solutions available today, the SQL Server 2016 edition ranks right up there amongst the very best. However it remains susceptible to SQL crashes which can lead to potential data loss. To avoid such a nightmarish scenario from unfolding in your organization, invest in a sql server recovery tool like DataNumen SQL Recovery application in advance. In the event of a crash you just need to run this tool and it will recover all the stored records from the compromised file within minutes. Moreover it can even extract data from a messed up SQL file stored on a virtual disk.
Alan Chen is President & Chairman of DataNumen, Inc., which is the world leader in data recovery technologies, including access recovery and sql recovery software products. For more information visit https://www.datanumen.com/