Skip to content

sp_QuickieStore: added expert mode T-SQL for plan forcing and hinting#684

Merged
erikdarlingdata merged 3 commits intoerikdarlingdata:devfrom
ReeceGoding:quickie-store-give-t-sql-for-plan-forcing-and-hinting
Feb 28, 2026
Merged

sp_QuickieStore: added expert mode T-SQL for plan forcing and hinting#684
erikdarlingdata merged 3 commits intoerikdarlingdata:devfrom
ReeceGoding:quickie-store-give-t-sql-for-plan-forcing-and-hinting

Conversation

@ReeceGoding
Copy link
Contributor

@ReeceGoding ReeceGoding commented Feb 28, 2026

Closes #678. In Expert Mode, this gives the main sp_QuickieStore output two new columns. One is for adding hints and the other is for either forcing or unforcing that row's plan. Unconditionally, the special output table that shows existing hints now also has a column for removing that row's hint. That output table is already gated off by Expert Mode or @Only_Queries_With_Hints = 1.

This was all a bit too easy. Maybe Erik's hard work has paid off? I worry that I've missed something big and obvious. It passes the tests that I've tried, but this all worked so well that I never needed to build any nasty cases.

I was unsure if the template that I've added for sp_query_store_set_hints should have had an actual hint rather than a placeholder. I know how much Erik likes FORCE_LEGACY_CARDINALITY_ESTIMATION, so I would understand having that rather than my newer_hints_go_here.

Whether you see the code for forcing a plan or unforcing is conditional on if that row's plan is forced. This makes more sense if you know that calling sp_query_store_force_plan unforces whatever plan is currently forced.

A @disable_optimized_plan_forcing = ? placeholder is deliberately left in place. I always start with = 0 and then switch to = 1 only if that fails. If there is a best practice for this that we should put in the template, then I do not know it.

Note that I have made no attempt to touch the @replica_group_id stuff. Even on SQL Server 2025, I believe that's pretty obscure? Maybe somebody should come back to it when the feature becomes more used.

I have not tested with exotic database names. Erik may know some good ones.

Appears in the same output table as the one detailing hints, so it is
quite naturally placed.
@erikdarlingdata
Copy link
Owner

Thanks for the contribution, Reece! This is a really clean, well-thought-out addition. The conditional toggle between force/unforce based on current plan state is a nice touch, and having the remove_hint column always visible in the hints output is the right call. Merging to dev now. 🎉

@erikdarlingdata erikdarlingdata merged commit 8b82116 into erikdarlingdata:dev Feb 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants