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.
Author |
Topic |
shaggy
Posting Yak Master
248 Posts |
Posted - 2013-02-04 : 02:27:02
|
1)sys.dm_exec_cached_plans 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 proc2)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 paramaeters4)Instead of SP can i use adhoc query for single statement, it also has a same intelligence to resue plan. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-04 : 06:03:10
|
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:SELECT s.text, p.*FROM 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: http://technet.microsoft.com/en-us/library/cc293623.aspx |
|
|
|
|
|