﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Programming / General  / Execution Plan Reuse / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 15:05:06 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>Offhand no idea then. I'd have to look at the plan cache myself to figure it out.</description><pubDate>Wed, 14 Nov 2012 08:17:31 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>Here's a few rows in their entirety:exec mt_amstas47 'AMS','78350438','19','4086','0','20121114 08:33','U'exec mt_amstas47 'AMS','78350438','18','4198','0','20121114 08:33','U'exec mt_amstas47 'AMS','78350438','22','16','0','20121114 08:33','U'(There are over 32K rows just calling this one sp; there are hundreds of these similar sp's). I'll have to find out "how" these sp's are called; I think from within an application.</description><pubDate>Wed, 14 Nov 2012 08:05:17 GMT</pubDate><dc:creator>jhager</dc:creator></item><item><title>RE: Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>If there's a select in the batch (which I've seen friom some apps), then the select portion gets a plan, but the EXEC portion has no plan, the plan for the procedure is separate and is the one you see with the text of 'CREATE PROCEDURE', and is reused.Has a select in, as in has a form kinda, something likeEXEC SomeProc @Param1, @Param2 OUTPUT; select @Param2</description><pubDate>Wed, 14 Nov 2012 07:47:31 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>Thanks for responding..perhaps one more question. I'm curious what the query is returning, then: I've got several thousand of these "EXEC mt_" rows returned that differ only by the value(s) of the variable(s). If these are not exec plans, what are they?</description><pubDate>Wed, 14 Nov 2012 07:36:02 GMT</pubDate><dc:creator>jhager</dc:creator></item><item><title>RE: Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>The batch EXEC ProcA has no execution plan, there's nothing in there, there's nothing to reuse. The plan for the actual execution of the procedure will be reused as per the normal reuse rules.</description><pubDate>Mon, 12 Nov 2012 11:03:00 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>Sorry if I was too cryptic/concise...1) Here's the query I run to check exec plan reuse:SELECT ECP.usecounts,ECP.refcounts,ECP.cacheobjtype,ECP.objtype,EST.[text]FROM	sys.dm_exec_cached_plans AS ECP		CROSS APPLY	sys.dm_exec_sql_text(ECP.plan_handle) AS ESTORDER BY	ECP.usecounts DESC,EST.[text];One row of output:usecounts    refcounts     cacheobjtype   objtype    text540253	  2	           Compiled Plan	Proc	      Create Proc mt_amstas30 @SourceID varchar(3),TaskID int,....Other rows of output (there are thousands of these, just the parameters different):usecounts    refcounts     cacheobjtype   objtype    text1	          2	           Compiled Plan	Prepared   exec mt_amstas30 'AMS','77985984',...1	          2	           Compiled Plan	Prepared   exec mt_amstas30 'AMS','77985995',...My goal is to reuse query plans whenever possible. If I'm interpreting the results of the query correctly, the exec plan for the SP mt_amstas30 is being reused, but the EXEC statements that "start" the SP are not. If this is true, is there a simple way to "start" the SP that does not create a new exec plan when the parameter strings change? My research on MSDN turns up RCP and ODBC calls that are far too complex...Thanks in advance for any guidance / help you can provide.</description><pubDate>Sat, 10 Nov 2012 05:08:00 GMT</pubDate><dc:creator>jhager</dc:creator></item><item><title>RE: Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>Huh?</description><pubDate>Fri, 09 Nov 2012 16:36:56 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>Execution Plan Reuse</title><link>http://www.sqlservercentral.com/Forums/Topic1383262-23-1.aspx</link><description>We have SPs that take several parameters; when I check the plan cache using ... FROM	sys.dm_exec_cached_plans AS ECP		CROSS APPLY	sys.dm_exec_sql_text(ECP.plan_handle) AS ESQL...I see lots of reuse for "Compiled Plan", "Proc", SQL Text like "Create Proc xyz..."but for "Compiled Plan","Prepared", SQL text like "EXEC xyz 'A','B','C'..." has no reuse.Is there a not complicated method to EXECute the SPs with plan reuse?</description><pubDate>Fri, 09 Nov 2012 14:56:40 GMT</pubDate><dc:creator>jhager</dc:creator></item></channel></rss>