In this post, we’ll look at a feature in SQL Server Query Store that was introduced in SQL Server 2022. I absolutely love Query Store, I use it so much I can barely remember what life was like without it.
One of the things that has been great about Query Store since its early days is the way you can force an execution plan for a query. This has saved me a number of times when a query’s performance has suddenly dropped off a cliff, the code hasn’t changed but the data distribution has and everyone is looking at me, the DBA to fix it. I can’t count the number of times I’ve forced the last good plan to resolve the issue. This is only a sticking plaster approach as with most approaches where forcing the optimizer is concerned – the query should then be added to the backlog for resolution but nonetheless this has got me out of a pinch on a number of occasions.
Click through to see how hints work. But just as with introducing normal hints into T-SQL code, you’ll want to make sure that you’re getting the behavior you expected, both now and in the future. As the underlying database details change, so too could the most appropriate hint choice.