In the past a problem we had when building SQLGrease was deadlock graphs only containing sql handles and statement start offsets. While this might give you the statement for parameterized adhoc sql or a stored procedure, it does not account for a cluttered plan cache due to non parameterized sql. This previous post explains the value of using query and plan hashes. The gist of it is it makes it more likely that you will find a query and plan in either query store or the plan cache when non-parameterized sql is used. With SQLGrease we build a fingerprint of a deadlock graph – this allows us to deduplicate frequently occurring deadlock scenarios. It also allows us to identify which deadlock scenarios occur most frequently so you know where to focus your tuning efforts. We built a round about solution to associate sql handles with query hashes; however, it’s not nearly as reliable if SQL Server does that work for you!
Final thoughts
Sometimes Microsoft gets it right when adding minor features with new SQL Server releases. Whoever came up with the idea to do that was either listening to the right feedback or has run into problems with plan cache/query store bloat. Happy tuning!