<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/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>LINQ Performance Pitfall - Deferred Execution</title><link>http://weblogs.asp.net/okloeten/archive/2008/05/27/6225197.aspx</link><description>When using LINQ, queries may bloat up to dozens of lines. My personal style is to take these queries and break them apart to smaller units of logic. To each unit of logic, I append a call to ToArray . @yosit asked me why I did it and I answered I was</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: LINQ Performance Pitfall - Deferred Execution</title><link>http://weblogs.asp.net/okloeten/archive/2008/05/27/6225197.aspx#6238182</link><pubDate>Sat, 31 May 2008 18:37:22 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6238182</guid><dc:creator>Omer van Kloeten</dc:creator><author>Omer van Kloeten</author><description>&lt;p&gt;Philip,&lt;/p&gt;
&lt;p&gt;It is true that the standard of LINQ is deferred execution, but it's not a rule. Also, as Oren (Ayende) said above, multiple statements sent to a database may be optimized better than you optimizing for it with .ToArray() calls.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6238182" width="1" height="1"&gt;</description></item><item><title>re: LINQ Performance Pitfall - Deferred Execution</title><link>http://weblogs.asp.net/okloeten/archive/2008/05/27/6225197.aspx#6237578</link><pubDate>Sat, 31 May 2008 14:59:51 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6237578</guid><dc:creator>Philip</dc:creator><author>Philip</author><description>&lt;p&gt;This is very true of LINQ in all incarnations (Object, XML, and SQL). Even LINQ to SQL table calls perform deferred execution. &lt;/p&gt;
&lt;p&gt;I think this is going to be one of the most difficult things for people new to LINQ to get their head around. We are going to be seeing a lot of problems in code before people think about deferred execution.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6237578" width="1" height="1"&gt;</description></item><item><title>Dew Drop - May 28, 2008 | Alvin Ashcraft's Morning Dew</title><link>http://weblogs.asp.net/okloeten/archive/2008/05/27/6225197.aspx#6226803</link><pubDate>Wed, 28 May 2008 15:02:13 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6226803</guid><dc:creator>Dew Drop - May 28, 2008 | Alvin Ashcraft's Morning Dew</dc:creator><author>Dew Drop - May 28, 2008 | Alvin Ashcraft's Morning Dew</author><description>&lt;p&gt;Pingback from &amp;nbsp;Dew Drop - May 28, 2008 | Alvin Ashcraft's Morning Dew&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6226803" width="1" height="1"&gt;</description></item><item><title>Interesting Finds: May 28, 2008</title><link>http://weblogs.asp.net/okloeten/archive/2008/05/27/6225197.aspx#6226763</link><pubDate>Wed, 28 May 2008 14:14:51 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6226763</guid><dc:creator>Jason Haley</dc:creator><author>Jason Haley</author><description>&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6226763" width="1" height="1"&gt;</description></item><item><title>re: LINQ Performance Pitfall - Deferred Execution</title><link>http://weblogs.asp.net/okloeten/archive/2008/05/27/6225197.aspx#6226257</link><pubDate>Wed, 28 May 2008 05:09:07 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6226257</guid><dc:creator>Omer van Kloeten</dc:creator><author>Omer van Kloeten</author><description>&lt;p&gt;Totally agree. This is only always true for LINQ to Objects and each other case of LINQ should be examined on its own accord.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6226257" width="1" height="1"&gt;</description></item><item><title>re: LINQ Performance Pitfall - Deferred Execution</title><link>http://weblogs.asp.net/okloeten/archive/2008/05/27/6225197.aspx#6225377</link><pubDate>Tue, 27 May 2008 21:38:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6225377</guid><dc:creator>Ayende Rahien</dc:creator><author>Ayende Rahien</author><description>&lt;p&gt;Note that this is only true for Linq statement that run in memory.&lt;/p&gt;
&lt;p&gt;If this is being sent to a DB or another location for execution, this would probably much better to let that location to handle this.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6225377" width="1" height="1"&gt;</description></item></channel></rss>