Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Multiple query plans for one query
with cte as
count(*) as [count],
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

This comment has been minimized.

Copy link

@hardik23197 hardik23197 commented Aug 8, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment