-
-
Save mjswart/109a641f35adb7ffcbe46a5f8d4bc259 to your computer and use it in GitHub Desktop.
Multiple query plans for one query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with cte as | |
( | |
select | |
count(*) as [count], | |
query_hash, | |
min(sql_handle) as sql_handle_example | |
from sys.dm_exec_query_stats | |
group by query_hash | |
) | |
select cte.*, t.text as query_text_example | |
from cte | |
cross apply sys.dm_exec_sql_text(sql_handle_example) t | |
where [count] > 100 | |
order by [count] desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is wonderful may i know as i get my query text from here there are 3 queries whose count is like 516,512,420 what steps should i take further now so that query doesn't make plans again and again but reuse the plans
Basically i want to know about what steps should be taken now to optimize there queries whose counts are this much