<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Performance consideration when using a Table Variable</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/15/performance-consideration-when-using-a-table-variable.aspx</link><description>This is nothing new to me (I come across this autumn 2007) and probably not to you either but I forgot about it and yesterday it came alive again. I often choose a table variable for performance reasons (if data is less than 1 page anyway) due to the</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Performance consideration when using a Table Variable</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/15/performance-consideration-when-using-a-table-variable.aspx#17822</link><pubDate>Thu, 15 Oct 2009 23:05:12 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:17822</guid><dc:creator>Nick Beagley</dc:creator><description>&lt;p&gt;I knew a plan that included a join on a table variable would never be parallel, i didn't realise it would also affect populating the table variable.&lt;/p&gt;
&lt;p&gt;There's a good comparison of table variables and temp tables on sql server central (and the comments): &lt;a rel="nofollow" target="_new" href="http://www.sqlservercentral.com/articles/Temporary+Tables/66720/"&gt;http://www.sqlservercentral.com/articles/Temporary+Tables/66720/&lt;/a&gt;&lt;/p&gt;</description></item><item><title>re: Performance consideration when using a Table Variable</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/15/performance-consideration-when-using-a-table-variable.aspx#17986</link><pubDate>Tue, 20 Oct 2009 02:03:44 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:17986</guid><dc:creator>Everest</dc:creator><description>&lt;p&gt;Amazing to me that a table variable, which is represented as a # table in tempdb, has all of the functionality chopped from it when comparint to its counterpart.&lt;/p&gt;
&lt;p&gt;Good article&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Lee&lt;/p&gt;</description></item><item><title>Output = MAXDOP 1</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/15/performance-consideration-when-using-a-table-variable.aspx#22807</link><pubDate>Thu, 04 Mar 2010 09:32:17 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22807</guid><dc:creator>SQL and the like</dc:creator><description>&lt;p&gt;It is widely know that data modifications on table variables do not support parallelism, Peter Larsson&lt;/p&gt;
</description></item><item><title>re: Performance consideration when using a Table Variable</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/15/performance-consideration-when-using-a-table-variable.aspx#22811</link><pubDate>Thu, 04 Mar 2010 10:06:40 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22811</guid><dc:creator>Peso</dc:creator><description>&lt;p&gt;Yes, I wrote that I came across this last time in 2007.&lt;/p&gt;
</description></item><item><title>re: Performance consideration when using a Table Variable</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/15/performance-consideration-when-using-a-table-variable.aspx#46777</link><pubDate>Mon, 24 Dec 2012 12:36:01 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:46777</guid><dc:creator>Martin Smith</dc:creator><description>&lt;p&gt;@Peso As I'm sure you realised since writing this operations on table variables are logged.&lt;/p&gt;
&lt;p&gt;@Nick - Plans that join on table variables can certainly be parallel but you may need an `OPTION (RECOMPILE)` hint for this to happen so that SQL Server takes account actual row counts. Here is an example &lt;a rel="nofollow" target="_new" href="http://stackoverflow.com/questions/1645846/can-queries-that-read-table-variables-generate-parallel-exection-plans-in-sql-se/8242831#8242831"&gt;http://stackoverflow.com/questions/1645846/can-queries-that-read-table-variables-generate-parallel-exection-plans-in-sql-se/8242831#8242831&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Also I'll plug my write up on the differences here &lt;a rel="nofollow" target="_new" href="http://dba.stackexchange.com/a/16386/3690"&gt;http://dba.stackexchange.com/a/16386/3690&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>