Battle of the Query Hints in Query Store

SQL Server
I recently presented a session on the Query Store at Data Saturday Rhineland and the question came up: If there's already a query hint on a query, what happens when you try to force a similar query hint? Yeah, OK, that is a weird one. I don't know the answer, but I'm about to find out. Setting up the Battle I've got this simple procedure I use a lot to illustrate bad parameter sniffing. In AdventureWorks, this query can produce up to five different plans, depending on the values called. Most of the time, it's one of two plans, which I'll get to in a minute. Here's the query: CREATE OR ALTER PROC dbo.ProductTransactionHistoryByReference (@ReferenceOrderID INT) AS BEGIN SELECT p.Name, p.ProductNumber, th.ReferenceOrderID FROM Production.Product AS p JOIN Production.TransactionHistory AS th…
Read More