BT

SQL Server 2016: Identify Regressions with Query Store

| by Jonathan Allen Follow 635 Followers on Jul 07, 2015. Estimated reading time: 1 minute |

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

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT