Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Plan-Reuse

Author  Topic 

kudzen
Starting Member

12 Posts

Posted - 2012-05-29 : 08:16:58
Hi there guys,

I'm trying to learn how plan reusing works and i run this query against my server

select stats.execution_count AS exec_count,
p.size_in_bytes as [size],
[sql].[text] as [plan_text]
from sys.dm_exec_cached_plans p
outer apply sys.dm_exec_sql_text (p.plan_handle) sql
join sys.dm_exec_query_stats stats ON stats.plan_handle = p.plan_handle

And it returns the same query text multiple times with execution count =1

I checked char by char if the full text is equal and it is.
I really don't understand.

Can you please help me figuring this out?

SQL Text returned by the above statement:

http://pastebin.com/index/iWE3ZtwN

PS: This is a stored procedure !

kudzen
Starting Member

12 Posts

Posted - 2012-05-29 : 12:12:40
I used perfmon to compare Batch Request/sec per Compilation/sec and this is how it seems
[url]http://imageshack.us/photo/my-images/232/trace.gif/[/url]

What's your opinion?

To many ad-hoc queries?
Go to Top of Page
   

- Advertisement -