Query hash

  • Is there any way to calculate the hash for the query which will the same as calculated by the engine?

  • Which hash are you referring to?

    Which tool are you wanting to calculate the hash with?

    Which engine are you referring to? The Mazda I have at the moment is pretty fast, but its engine is rubbish with hashes.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • I don't think you can because the hash is created internally based on a structure in the optimizer, not the T-SQL text, that would also have to be recreated. You could probably run the debugger to figure all this out. What do you need it for?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey wrote:

    I don't think you can because the hash is created internally based on a structure in the optimizer, not the T-SQL text, that would also have to be recreated. You could probably run the debugger to figure all this out. What do you need it for?

     

    Ah, that hash. I was thinking that the OP was referring to something like HASHBYTES or CHECKSUM.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Really curious what the use case and need is though.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant,

    I have EF Core interceptor created for my app. I want to calculate such hash value for the query being executeted. Next I want to match this hash to the hash stored in DMV views.

  • Ah, interesting use of the tools. Unfortunately, I don't know of a way to do it. I'm not saying it can't be done, just that there's not a way I'm aware of.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thank you Grant for your reply.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply