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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cached Plan
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

248 Posts

Posted - 02/04/2013 :  02:27:02  Show Profile  Reply with Quote
what is cached obhecttype as "prepared" ?
even though i execute stroed proc the object type for that is displayed as prepared, i suppose it should be proc

2)can i able to get the executed exec statement from cache?

3)plan reuse,It is ok to resue the same plan for different set of paramaeters

4)Instead of SP can i use adhoc query for single statement, it also has a same intelligence to resue plan.

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 02/04/2013 :  06:03:10  Show Profile  Reply with Quote
1. Not sure why cachobjtype is showing up us prepared. Is the next column (objtype) showing Proc? Also are you running the query from SSMS or from a client?

2. To get the text of the query, use this:
	sys.dm_exec_cached_plans p
	CROSS APPLY sys.dm_exec_sql_text (p.plan_handle) s

3. It is good, but sometimes bad. It is good because reusing query plans avoids the overhead of regenerating the query plan. But, sometimes, if the previously generated query plan is not a good fit for a new set of parameters, the query can turn out to be inefficient. If you google for "parameter sniffing" you will find information on this issue.

4. It is possible for adhoc queries to reuse plan (sometimes) - see a good discussion here:
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000