Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News SQL Server 2016: Identify Regressions with Query Store

SQL Server 2016: Identify Regressions with Query Store

For most developers, performance regressions can usually be traced back to a specific event such a major influx of users or a code change. For the database developer, it isn’t always so easy. As indexes are rebuilt and statistics updated, SQL Server may decide to “rewrite” your code by regenerating the execution plan. Without the right backup and production-grade hardware, seeing what changed in the execution plan can be neigh impossible.

At least it was. With SQL Server 2016, Microsoft will start storing historic execution plans using a feature called Query Store. When enabled, the Query Store will log information about each query including:

  • Number of executions
  • Execution time
  • Memory Consumption
  • Logical Reads
  • Logical Writes
  • Physical Reads
  • Number of execution plan changes

To reduce the load on the server, this information is aggregated into fixed windows. If you need more precise data, you should look to Extended Events instead.

The easiest way to use this information is to open the Regressed Queries view.

This tool will allow you to see regressions based on any of the recorded metrics. If you see a regression, you have the option to force SQL Server to use an older execution plan.

Query Store Tuning

Because tracking metrics like this can be expensive, SQL Server allows you to tune the Query Store. Factors you can adjust include the size of the aggregate window in minutes, the max size of the query store in MB, the maximum number of execution plans to store. You can also tell the Query Store to only record queries that meet certain criteria.

Programmatic Access

As with most SQL Server features, all the information you see in the Regressed Queries tool can be accessed directly using a collection of management views.

Rate this Article