DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Resolving Parameter Sensitivity With Parameter Sensitive Plan Optimization in SQL Server 2022
  • Comparing Managed Postgres Options on The Azure Marketplace
  • Useful System Table Queries in Relational Databases
  • Introducing Graph Concepts in Java With Eclipse JNoSQL

Trending

  • Distributed Consensus: Paxos vs. Raft and Modern Implementations
  • Useful System Table Queries in Relational Databases
  • Bridging UI, DevOps, and AI: A Full-Stack Engineer’s Approach to Resilient Systems
  • Is Big Data Dying?
  1. DZone
  2. Data Engineering
  3. Databases
  4. Query Store as an Upgrade Tool

Query Store as an Upgrade Tool

A clever way to use the Query Store.

By 
Grant Fritchey user avatar
Grant Fritchey
·
Mar. 22, 21 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
6.5K Views

Join the DZone community and get the full member experience.

Join For Free

There are a lot of uses for Query Store, but one of the most interesting is as an upgrade tool. We all know that upgrades in SQL Server can be more than a little bit nerve wracking. No matter how much you tested stuff in lower environments, deploying an update to production might result in performance issues as your code hits a regression. This is even more true when upgrading from versions of SQL Server prior to 2014 to anything 2014 and above. That’s because of the new cardinality estimation engine introduced in 2014. Most queries won’t notice it. Some queries will benefit from the better estimates. A few, problematic, queries will suffer. This is where Query Store can be used as an upgrade tool.

The Steps

We’re going to use two of the functions that Query Store offers us to turn it into a tool for upgrading SQL Server. First, of course, is the ability of Query Store to capture query behaviors. The second is the ability of Query Store to force the use of execution plans. Between these two pieces of functionality, you can have safer, saner, upgrades. Here are the steps to make this work.

  1. Upgrade your server, whether in place or side-by-side. Get your databases on to the new server, detach/attach, backup & restore, doesn’t matter.
  2. Leave the compatibility level on the database(s) in question at the old version, whatever that was.
  3. Enable Query Store
  4. Run the load on your machine. A day, a week, a month, you figure that out for your system.
  5. Switch the compatibility level on the database(s) to the new version.
  6. Query Store has a report that will show regressed queries. Or, your users may alert you to queries that are no longer performing in the same way.
  7. Take a look at the query & plan in Query Store. If there’s a plan that was in use prior to the compatibility switch that was running faster than the new plan, force that old plan.
  8. Circle back to the query and tune it (it needs it). Do this secure in the knowledge, it’s running the old way while you figure it out.

That’s it. Is this 100% fool proof? Of course not. Any number of issues could arise. You may have such a massive transaction load that Query Store doesn’t work for you out of the box. It could be that the performance differences are reflected in execution plans. There might not be a confirmed plan that works better. All sorts of stuff. However, is this method going to work for most people, most of the time?

Yes.

Conclusion

Any time you can increase the reliability and stability of your production systems, especially across upgrades, I’d sure jump on it. Query Store as an upgrade tool is pretty good. It’s really easy to use. It’s built right in to 2016 and above SQL Server versions. You don’t have to pay for it. It’s right there. Take advantage of it.

I have a whole bunch of posts on how to use Query Store, plus I co-wrote a book on the topic. With all this, you should have enough to get started with Query Store.

Database

Published at DZone with permission of Grant Fritchey, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Resolving Parameter Sensitivity With Parameter Sensitive Plan Optimization in SQL Server 2022
  • Comparing Managed Postgres Options on The Azure Marketplace
  • Useful System Table Queries in Relational Databases
  • Introducing Graph Concepts in Java With Eclipse JNoSQL

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!