Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
SQL

SQL Server: Fix Query Store Forcing the Slower Cached Plan

- 24.11.26 - ErcanOPAK

🗄️ SQL Server: Fix Query Store Forcing the Slower Cached Plan

Query Store’s plan forcing, whether applied automatically or via sp_query_store_force_plan, pins a specific execution plan to a query based on whatever plan looked best at the time it was forced, and that pin stays in effect regardless of how the underlying data distribution changes afterward. A forced plan chosen when a table was small can become the actively worse choice once the table grows, but Query Store has no mechanism to un-force a plan on its own; it keeps applying the pinned plan indefinitely, actively overriding whatever the optimizer would now choose if left alone, until someone manually intervenes.

🔎 The Problem

-- A plan was forced weeks ago when this query ran fastest
-- with a nested loop join against a then-small table:
EXEC sp_query_store_force_plan @query_id = 482, @plan_id = 917;

-- Table has since grown 50x. The optimizer would now pick a
-- hash join instead, but the forced plan overrides that choice
-- on every execution - query duration has crept up for weeks
-- with nothing in a normal plan review explaining why, since
-- the forced plan still 'succeeds' without error

✅ Fix: Review Forced Plans Against Current Data

  • Review sys.query_store_plan.is_forced_plan periodically against current table sizes and statistics, specifically for any plan forced more than a few weeks earlier, since a forced plan is a decision frozen in time, not a rule the optimizer keeps re-validating.
  • Use sp_query_store_unforce_plan to release the pin before investigating a slow query that Query Store history shows was previously forced, rather than tuning indexes or rewriting the query against a plan that’s being artificially held in place.
  • Prefer Query Store’s automatic plan regression correction, where supported, over a permanent manual force when the goal is just to recover from a specific regression, since automatic correction can adapt again later while a manual force never will on its own.

🚨 Why This Is Dangerous

  • A forced plan silently overriding the optimizer’s current best judgment means every subsequent tuning effort, new indexes, updated statistics, rewritten queries, can be completely ineffective, because the actual plan in use was never going to change no matter what else got tuned around it.

Forcing a plan freezes a decision in time — the data keeps moving, and Query Store will happily keep applying yesterday’s best answer to today’s very different table.

— Database Engineer

Related posts:

SQL Server Query Store: Proactive Performance Monitoring

SQL Server Query Store: Proactive Performance Monitoring

Set Identity Insert On/Off in MSSQL

Set Identity Insert On/Off in MSSQL

SQL COUNT(*) Is Slower Than Expected

SQL COUNT(*) Is Slower Than Expected

Views: 9
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

WordPress: Fix a Reusable Block Losing Edits After Pattern Sync
HTML5: Fix a Template’s Content Not Cloning Event Listeners

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 629 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com