Kendra Little digs into a problem:
This is the worst bug I’ve found in SQL Server to date. Previously, my top find was SQL Server Online Index Rebuild sometimes happens offline without warning. This one has taken top slot because it makes my life more difficult on a daily basis.
Background: SQL Server generates a
query_hash
for each query. This is stored insys.query_store_query
and it’s one of the primary ways you can identify what a query is across different Query Stores, or even the same Query Store over time, as surrogatequery_id
values get reset if Query Store is cleared or data ages on. Thequery_hash
is a “Zobrist hash over the shape of the individual query, based on the bound (input) logical query tree. Query hints aren’t included as part of the hash.” (Source)Except that’s wrong.
Read the whole thing.