<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Multiple Execution Paths</title>
	<atom:link href="http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/</link>
	<description>A discussion on SQL Server</description>
	<lastBuildDate>Tue, 07 Feb 2012 14:50:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Gail</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-1217</link>
		<dc:creator>Gail</dc:creator>
		<pubDate>Wed, 15 Dec 2010 05:48:39 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-1217</guid>
		<description>As always, it depends. :-)

If a proc is running many times a second you do not want it recompiling on each execution. The overhead will be unpleasant. If the proc is running once a day the recompile overhead is far less of a problem.</description>
		<content:encoded><![CDATA[<p>As always, it depends. <img src='http://sqlinthewild.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If a proc is running many times a second you do not want it recompiling on each execution. The overhead will be unpleasant. If the proc is running once a day the recompile overhead is far less of a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-1210</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 14 Dec 2010 22:26:58 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-1210</guid>
		<description>I worry about the recompile option because in a high load (hundred calls per sec) the time and processor spent to recompile could be big ( agree or not ?!). 
The option to have more procedures is the right choice IMO.</description>
		<content:encoded><![CDATA[<p>I worry about the recompile option because in a high load (hundred calls per sec) the time and processor spent to recompile could be big ( agree or not ?!).<br />
The option to have more procedures is the right choice IMO.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tsquare</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-538</link>
		<dc:creator>Tsquare</dc:creator>
		<pubDate>Fri, 05 Mar 2010 23:07:49 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-538</guid>
		<description>Great Blog!......There&#039;s always something here to make me laugh...Keep doing what ya do :)</description>
		<content:encoded><![CDATA[<p>Great Blog!&#8230;&#8230;There&#8217;s always something here to make me laugh&#8230;Keep doing what ya do <img src='http://sqlinthewild.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gail</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-537</link>
		<dc:creator>Gail</dc:creator>
		<pubDate>Mon, 07 Dec 2009 15:23:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-537</guid>
		<description>If you&#039;ve got a proc with multiple if-else branches, based of multiple parameters then you are probably way better off breaking it down into multiple smaller procs. Not sure why you&#039;re concerned with the numbers, the same number queries would exist in the single proc, it&#039;s just a matter of moving them elsewhere.</description>
		<content:encoded><![CDATA[<p>If you&#8217;ve got a proc with multiple if-else branches, based of multiple parameters then you are probably way better off breaking it down into multiple smaller procs. Not sure why you&#8217;re concerned with the numbers, the same number queries would exist in the single proc, it&#8217;s just a matter of moving them elsewhere.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aalamjeet Singh</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-536</link>
		<dc:creator>Aalamjeet Singh</dc:creator>
		<pubDate>Mon, 07 Dec 2009 14:26:54 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-536</guid>
		<description>What happens if the there are more than one parameters which can have multiple combinations of values while calling the master proc? We can&#039;t have n child procs for n number of combinations if n is a large number!</description>
		<content:encoded><![CDATA[<p>What happens if the there are more than one parameters which can have multiple combinations of values while calling the master proc? We can&#8217;t have n child procs for n number of combinations if n is a large number!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gail</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-535</link>
		<dc:creator>Gail</dc:creator>
		<pubDate>Sat, 10 Oct 2009 08:48:13 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-535</guid>
		<description>Bear in mind this was a simplified example. It&#039;s possible to get this problem when all indexes are covering, eg through inappropriate joins or other operators. It&#039;s not just an indexing question.

It&#039;s just a bit harder to generate such an example, which is why I stuck to something simple.</description>
		<content:encoded><![CDATA[<p>Bear in mind this was a simplified example. It&#8217;s possible to get this problem when all indexes are covering, eg through inappropriate joins or other operators. It&#8217;s not just an indexing question.</p>
<p>It&#8217;s just a bit harder to generate such an example, which is why I stuck to something simple.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Troy</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-534</link>
		<dc:creator>Troy</dc:creator>
		<pubDate>Fri, 09 Oct 2009 21:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-534</guid>
		<description>Thanks for the additional information about the index. I had guessed that there must be one in your example, and defined one that used the TransactionType for the index key, but additionally included the TransactionDate. This has the effect of eliminating the key lookup in the suboptimal plan, so the reads don&#039;t go through the roof as in your example.

So the 2nd recommendation that I hope your readers will keep in mind is to be sure your indexing design is optimal for the types of queries you&#039;re running.</description>
		<content:encoded><![CDATA[<p>Thanks for the additional information about the index. I had guessed that there must be one in your example, and defined one that used the TransactionType for the index key, but additionally included the TransactionDate. This has the effect of eliminating the key lookup in the suboptimal plan, so the reads don&#8217;t go through the roof as in your example.</p>
<p>So the 2nd recommendation that I hope your readers will keep in mind is to be sure your indexing design is optimal for the types of queries you&#8217;re running.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gail</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-533</link>
		<dc:creator>Gail</dc:creator>
		<pubDate>Thu, 08 Oct 2009 16:05:42 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-533</guid>
		<description>SQL 2008. 2005 behaves exactly the same way. I did this as a presentation, used SQL 2008 twice and 2005 once.

The point is not avoiding recompiles, the point is that SQL doesn&#039;t recompile and continues using a cached plan even in cases when it&#039;s highly inefficient.

Make sure there is an index on TransactionType. I&#039;m not sure if there&#039;s one on that column in the default adventureworks. Without an index, you&#039;ll get a tablescan no matter what because there&#039;s no other way to evaluate the query
USE [Adventureworks]
GO
CREATE NONCLUSTERED INDEX [IX_TransactionHistory_TransactionType] ON [Production].[TransactionHistory]
([TransactionType] ASC)</description>
		<content:encoded><![CDATA[<p>SQL 2008. 2005 behaves exactly the same way. I did this as a presentation, used SQL 2008 twice and 2005 once.</p>
<p>The point is not avoiding recompiles, the point is that SQL doesn&#8217;t recompile and continues using a cached plan even in cases when it&#8217;s highly inefficient.</p>
<p>Make sure there is an index on TransactionType. I&#8217;m not sure if there&#8217;s one on that column in the default adventureworks. Without an index, you&#8217;ll get a tablescan no matter what because there&#8217;s no other way to evaluate the query<br />
USE [Adventureworks]<br />
GO<br />
CREATE NONCLUSTERED INDEX [IX_TransactionHistory_TransactionType] ON [Production].[TransactionHistory]<br />
([TransactionType] ASC)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Troy</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-532</link>
		<dc:creator>Troy</dc:creator>
		<pubDate>Thu, 08 Oct 2009 15:10:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-532</guid>
		<description>Avoiding recompiles in conditional stored procs via sub-procs is a technique I used in the 6.5 through 2000 days, but I didn&#039;t have a chance to cycle back and see if it still applies for SS2K5 with the new statement-level recompilation feature.

I haven&#039;t yet been able to convince myself that the sub-proc technique is still necessary...

What version and build of SQL Server are you using? I&#039;m unable to duplicate the behavior using SS2K5 Developer Edition 9.00.4035.00 (SP3) on an x86.

I artificially increased the size of the table to 6.8 million rows (copies of itself over and over). Was there any other manipulation you did for the data distribution? Any changes to the indexing as deployed in the AW sample?

Thanks,
TroyK</description>
		<content:encoded><![CDATA[<p>Avoiding recompiles in conditional stored procs via sub-procs is a technique I used in the 6.5 through 2000 days, but I didn&#8217;t have a chance to cycle back and see if it still applies for SS2K5 with the new statement-level recompilation feature.</p>
<p>I haven&#8217;t yet been able to convince myself that the sub-proc technique is still necessary&#8230;</p>
<p>What version and build of SQL Server are you using? I&#8217;m unable to duplicate the behavior using SS2K5 Developer Edition 9.00.4035.00 (SP3) on an x86.</p>
<p>I artificially increased the size of the table to 6.8 million rows (copies of itself over and over). Was there any other manipulation you did for the data distribution? Any changes to the indexing as deployed in the AW sample?</p>
<p>Thanks,<br />
TroyK</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave F</title>
		<link>http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/comment-page-1/#comment-531</link>
		<dc:creator>Dave F</dc:creator>
		<pubDate>Mon, 21 Sep 2009 15:27:35 +0000</pubDate>
		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=284#comment-531</guid>
		<description>Having come from a C++ background, I instinctively use sub procedures. Now I know it&#039;s not a bad habit after all. Thanks.</description>
		<content:encoded><![CDATA[<p>Having come from a C++ background, I instinctively use sub procedures. Now I know it&#8217;s not a bad habit after all. Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

