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

Is it possible to retrieve/get the query hash of a query without searching the DMOs?

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

Problem

Sometimes I want to compare the performance of two queries by running them multiple times while an extended events session is capturing the metrics.
To avoid too much filtering and/or noise I would like to filter my extended events based on the query hashes.

In order to do that I need the query hash. So far I have had to look them up in the DMOs based on the text. But then I spend as much time finding the query hashes as I do just filtering the extended event session in other ways.

So is there an easier/quicker way to retrieve/get the query hash?

Solution

If you have the queries you're testing in front of you, you can get either an estimated or actual plan. When the query plan pops up, highlight the select operator and hit F4. You'll probably need to toggle around between plan operators to get properties to show up for the one you want, but when they do you'll see the QueryHash, QueryPlanHash, and SQLHandle of your query.

Context

StackExchange Database Administrators Q#246958, answer score: 7

Revisions (0)

No revisions yet.