Microsoft SQL Server Query Store Forcing plan for query

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

SQL Query optimizer will choose the baes possible plan that he can find for some query. If you can find some plan that works optimally for some query, you can force QO to always use that plan using the following stored procedure:

EXEC sp_query_store_unforce_plan @query_id, @plan_id

From this point, QO will always use plan provided for the query.

If you want to remove this binding, you can use the following stored procedure:

EXEC sp_query_store_force_plan @query_id, @plan_id

From this point, QO will again try to find the best plan.



Got any Microsoft SQL Server Question?