HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Does Microsoft release its SQL Query Hash Algorithm..?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sqlquerymicrosofthashalgorithmitsreleasedoes

Problem

We use SQL Spotlight in our environment. it's pretty handy.
we use particularly the output of sys.dm_exec_requests and sys.dm_exec_query_stats.

Spotlight pulls the query plan from the plan cache for you using the hash which is nice.

Problem is, unless you're experienced with the code base, it's quite difficult to know where that query came from.

I had an idea that if I could:

  • Parse the codebase



  • Pull the SQL queries



  • Hash them the same way microsoft does



This way I could do quick matches of the hash to be able see where in the codebase a particular query came from.

Alternatively I'd have to do some very slow regex...

Solution

Does Microsoft release its SQL Query Hash Algorithm..?

No, Microsoft does not release the hashing algorithm. Additionally, hashing happens at a different layer than original query text - so even if you had the algorithm, you'd still need to normalize like SQL Server does, first.


This way I could do quick matches of the hash to be able see where in the codebase a particular query came from.

This assumes there also isn't anything like dynamic sql, SMO, etc., where there isn't an actual plain text query.

Context

StackExchange Database Administrators Q#183046, answer score: 8

Revisions (0)

No revisions yet.