Introduction to SQL Server Query Store

Learn SQL with Udemy

For an instructor lead, in-depth look at learning SQL click below.


SQL Server Query Store is a performance monitoring tool introduced in SQL Server 2016. It acts as flight recorder or ‘black box’, capturing the history of executed SQL queries. The Query Store feature provides DBAs with insight on query plan choice, and performance. It simplifies performance troubleshooting by helping you quickly find the longest running and most resource-intensive queries.

Enabling Query Store

The first step to using Query Store is to enable it, as it is not turned on by default. This can be done with the following SQL command:

Configuring the Query Store

Once Query Store is enabled, you can configure its settings to suit your environment. Use the following command to set the size of the Query Store in MB:

Viewing Query Store Data

You can use the following queries to view some of the Query Store runtime and wait statistics:

Clearing Query Store Data

To clear out Query Store data, use the following command:

Conclusion

The SQL Server Query Store is a powerful tool for tracking and optimizing your SQL queries. It’s easy to setup, simple to use, and provides valuable insights into your database’s performance. It’s definitely a tool worth integrating into your SQL Server toolkit.

Leave a Comment