<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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 Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx</link><description>I've written a few articles about Linq now and you know I was a big fan of compiled queries in Linq but what do they cost? Or more specifically, how many times to you have to use a compiled query in order for the cost of compilation to pay for itself?</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Geek Lectures - Things geeks should know about &amp;raquo; Blog Archive   &amp;raquo;  Performance Quiz #13 &amp;#8212; Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7078985</link><pubDate>Fri, 11 Jan 2008 23:28:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7078985</guid><dc:creator>Geek Lectures - Things geeks should know about » Blog Archive   »  Performance Quiz #13 — Linq to SQL compiled queries cost</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://geeklectures.info/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost/"&gt;http://geeklectures.info/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost/&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Geek Lectures - Things geeks should know about &amp;raquo; Blog Archive   &amp;raquo;  Performance Quiz #13 &amp;#8212; Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7078996</link><pubDate>Fri, 11 Jan 2008 23:28:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7078996</guid><dc:creator>Geek Lectures - Things geeks should know about » Blog Archive   »  Performance Quiz #13 — Linq to SQL compiled queries cost</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://geeklectures.info/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost/"&gt;http://geeklectures.info/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost/&lt;/a&gt;&lt;/p&gt;</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7079722</link><pubDate>Sat, 12 Jan 2008 00:28:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7079722</guid><dc:creator>Anonymouse</dc:creator><description>&lt;p&gt;Only once since the query must be &amp;quot;compiled&amp;quot; anyway.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7080291</link><pubDate>Sat, 12 Jan 2008 01:22:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7080291</guid><dc:creator>Grant</dc:creator><description>&lt;p&gt;[Only once since the query must be &amp;quot;compiled&amp;quot; anyway.]&lt;/p&gt;
&lt;p&gt;I doubt that.&lt;/p&gt;
&lt;p&gt;There is almost certainly additional overhead in finding out if the query has already been compiled (using a hashcode or similar mechanism?) and allocating storage for the compiled query in some sort of collection of compiled queries.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7080448</link><pubDate>Sat, 12 Jan 2008 01:36:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7080448</guid><dc:creator>JamesNT</dc:creator><description>&lt;p&gt;I doubt it as well. &amp;nbsp;Unfortunately, I do not know enough about Linq to give an informed answer. &amp;nbsp;Therefore, I will be watching Rico's blog with interest as he posts the answer.&lt;/p&gt;
&lt;p&gt;JamesNT&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7081664</link><pubDate>Sat, 12 Jan 2008 03:29:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7081664</guid><dc:creator>Oleg Mihailik</dc:creator><description>&lt;p&gt;There is no implicit caching of compiled queries, so I vote for 'once' as well.&lt;/p&gt;
&lt;p&gt;That's the problem: LINQ doesn't remember the expressions when they are executed twice or more. It always re-interprets an expression tree from scratch.&lt;/p&gt;
&lt;p&gt;Otherwise, we wouldn't need CompiledQuery functionality in the first place.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7089973</link><pubDate>Sat, 12 Jan 2008 18:23:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7089973</guid><dc:creator>Peter Ritchie</dc:creator><description>&lt;p&gt;It depends on the query. &amp;nbsp;Taking into account the cost of the compile, I've had some compiled queries take as many as 15 executions before they paid for themself.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7091765</link><pubDate>Sun, 13 Jan 2008 01:32:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7091765</guid><dc:creator>Galcho</dc:creator><description>&lt;p&gt;I think we need to use the following formula to find number fo execution where time is same for both cases&lt;/p&gt;
&lt;p&gt;X.Ec + Tc = X.Er&lt;/p&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;p&gt;X = Tc /(Er - Ec)&lt;/p&gt;
&lt;p&gt;where &lt;/p&gt;
&lt;p&gt;X - number of executions&lt;/p&gt;
&lt;p&gt;Ec - Execution of compiled query&lt;/p&gt;
&lt;p&gt;Tc - time needed for compilation&lt;/p&gt;
&lt;p&gt;Er - execution of raw query &lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7105114</link><pubDate>Mon, 14 Jan 2008 09:22:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7105114</guid><dc:creator>omario</dc:creator><description>&lt;p&gt;I think queries are cached for &amp;nbsp;the lifetime of thedatacontext. &lt;/p&gt;
&lt;p&gt;And it worth compiling query if you use it with different datacontexts more than once.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7105654</link><pubDate>Mon, 14 Jan 2008 11:22:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7105654</guid><dc:creator>Alexey Lavnikov</dc:creator><description>&lt;p&gt;I doubt that queries are cached in DataContext.&lt;/p&gt;
&lt;p&gt;I think if you use same query more than once, compiled queries are better.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7109231</link><pubDate>Mon, 14 Jan 2008 19:23:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7109231</guid><dc:creator>JamesCurran</dc:creator><description>&lt;p&gt;Well, from my testing (using the query Rico gave), the pay-off is immediate.&lt;/p&gt;
&lt;p&gt;I'm going to assume the the Comments editor is going to mangle the chart below, so to summarize, Compiled *always* wins, even for just one repitition. &amp;nbsp;At higher repetitions, the ratio settles at 5:1, but oddly, at low reps, compiled win by as much as 25:1. (Some -- but not all -- of that can be attributed to the timer resolution)&lt;/p&gt;
&lt;p&gt;Reps &amp;nbsp; &amp;nbsp; &amp;nbsp;uncompiled Compiled &amp;nbsp;ratio&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; :00.25 &amp;nbsp; &amp;nbsp; :00.014 &amp;nbsp;18:1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; :00.37 &amp;nbsp; &amp;nbsp; :00.015 &amp;nbsp;25:1&lt;/p&gt;
&lt;p&gt; &amp;nbsp; 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; :00.27 &amp;nbsp; &amp;nbsp; :00.02 &amp;nbsp; 14:1&lt;/p&gt;
&lt;p&gt; &amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; :00.81 &amp;nbsp; &amp;nbsp; :00.06 &amp;nbsp; 13:1&lt;/p&gt;
&lt;p&gt; &amp;nbsp;500 &amp;nbsp; &amp;nbsp; &amp;nbsp; :01.98 &amp;nbsp; &amp;nbsp; :00.38 &amp;nbsp; &amp;gt;5:1&lt;/p&gt;
&lt;p&gt; 5000 &amp;nbsp; &amp;nbsp; &amp;nbsp; :14.86 &amp;nbsp; &amp;nbsp; :03.10 &amp;nbsp; &amp;lt;5:1&lt;/p&gt;
&lt;p&gt;50000 &amp;nbsp; &amp;nbsp; &amp;nbsp;2:26 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;:27 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;gt;5:1&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7109326</link><pubDate>Mon, 14 Jan 2008 19:34:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7109326</guid><dc:creator>Peter Ritchie</dc:creator><description>&lt;p&gt;James, your times don't seem to detail the compilation time? &amp;nbsp;My tests show that 1 repetition uncompiled is slower than compiling and 1 repetition of the compiled object.&lt;/p&gt;
&lt;p&gt;Although, I haven't tested specifically with Rico's example, in my tests the compilation time begins to be offset at 15 repetitions. &amp;nbsp;As I stated earlier, this offset is likely dependant on database and the query involved.&lt;/p&gt;
</description></item><item><title>Rico teases us with a LINQ to SQL performance quiz</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7109429</link><pubDate>Mon, 14 Jan 2008 19:46:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7109429</guid><dc:creator>The Wayward WebLog</dc:creator><description>&lt;p&gt;Check it out and see if you know the answer. Rico's Performance Tidbits&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7109533</link><pubDate>Mon, 14 Jan 2008 19:53:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7109533</guid><dc:creator>JamesCurran</dc:creator><description>&lt;p&gt;Here is my code for the compiled case. &amp;nbsp;The time is for one call to this method. (&amp;quot;reps&amp;quot; is a hard-code static const which I manually change between runs.) &amp;nbsp;(&amp;quot;total&amp;quot; is used to prevent the compiler from eliding unused code, and to compare with the results from Test1() which was the uncompiled version.)&lt;/p&gt;
&lt;p&gt;static int &amp;nbsp;Test2()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;NorthwindDataContext nwdc = new NorthwindDataContext(&amp;quot;(local)&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;var fq = CompiledQuery.Compile((NorthwindDataContext nw) =&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;(from o in nw.Orders&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; select new&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OrderID = o.OrderID,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CustomerID = o.CustomerID,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; EmployeeID = o.EmployeeID,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ShippedDate = o.ShippedDate&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; }).Take(5)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int total = 0;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;for (int i = 0; i &amp;lt; reps; ++i)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; var t= fq.Invoke(nwdc);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (var a in t)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total += a.OrderID;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return total;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7110368</link><pubDate>Mon, 14 Jan 2008 21:29:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7110368</guid><dc:creator>ricom</dc:creator><description>&lt;p&gt;James: &amp;nbsp;Things you want to control for at low reps:&lt;/p&gt;
&lt;p&gt;-jitting time (run once and throw away that result to get all the code jitted)&lt;/p&gt;
&lt;p&gt;-state of the connection pool (you don't want to charge the cost of making the connection to one algorithm, and not the other so make several connections first and discard those results too)&lt;/p&gt;
&lt;p&gt;What I did was I ran several thousand batches first of both cases, discarded those results, and then measured. &amp;nbsp;Also I tried them in different orders to make sure that the later runs were not penalized by say more things on the GC heap (they were not as it turns out but I controlled for it anyway)&lt;/p&gt;
&lt;p&gt;I don't understand how the compiled query can possibily win in the single use case :)&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7110394</link><pubDate>Mon, 14 Jan 2008 21:32:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7110394</guid><dc:creator>Peter Ritchie</dc:creator><description>&lt;p&gt;If I include the cost of the compilation in the times, I get ratios like this with that sample code:&lt;/p&gt;
&lt;p&gt;	uncompiled	compiled	&lt;/p&gt;
&lt;p&gt;1	00:00:00.1047737	00:00:00.0903456	1.2:1&lt;/p&gt;
&lt;p&gt;5	00:00:00.0921325	00:00:00.1044020	0.8:1&lt;/p&gt;
&lt;p&gt;10	00:00:00.0982715	00:00:00.1024622	1,0:1&lt;/p&gt;
&lt;p&gt;50	00:00:00.1724429	00:00:00.1112768	1.5:1&lt;/p&gt;
&lt;p&gt;500	00:00:00.6105094	00:00:00.2092043	2.9:1&lt;/p&gt;
&lt;p&gt;5000	00:00:05.0588695	00:00:01.2370046	4.1:1&lt;/p&gt;
&lt;p&gt;50000	00:00:49.9114562	00:00:11.3373295	4.4:1&lt;/p&gt;
&lt;p&gt;Now, with a different query on the same northwind database the results are different again:&lt;/p&gt;
&lt;p&gt;	uncompiled	compiled	&lt;/p&gt;
&lt;p&gt;1	00:00:00.4928271	00:00:00.3322023	1.5:1&lt;/p&gt;
&lt;p&gt;5	00:00:01.1390319	00:00:01.1036043	1.0:1&lt;/p&gt;
&lt;p&gt;10	00:00:02.1391678	00:00:02.0752555	1.0:1&lt;/p&gt;
&lt;p&gt;50	00:00:10.0530105	00:00:09.6794834	1.0:1&lt;/p&gt;
&lt;p&gt;500	00:01:41.2241573	00:01:35.6616519	1.1:1&lt;/p&gt;
&lt;p&gt;And the copde/compiled-query is:&lt;/p&gt;
&lt;p&gt;static int Test()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;	NorthwindDataContext nwdc = new NorthwindDataContext(@&amp;quot;(local)\SQLExpress&amp;quot;);&lt;/p&gt;
&lt;p&gt;	int total = 0;&lt;/p&gt;
&lt;p&gt;	Stopwatch stopwatch = new Stopwatch();&lt;/p&gt;
&lt;p&gt;	stopwatch.Start();&lt;/p&gt;
&lt;p&gt;		var cq = CompiledQuery.Compile((NorthwindDataContext nw) =&amp;gt;&lt;/p&gt;
&lt;p&gt;	(from customer in nw.Customers&lt;/p&gt;
&lt;p&gt;				select new&lt;/p&gt;
&lt;p&gt;				{&lt;/p&gt;
&lt;p&gt;					Customer = customer,&lt;/p&gt;
&lt;p&gt;					Orders = from o in nw.Orders&lt;/p&gt;
&lt;p&gt;							 join co in nw.Orders&lt;/p&gt;
&lt;p&gt;							 on o.CustomerID equals co.CustomerID&lt;/p&gt;
&lt;p&gt;							 where co.CustomerID == customer.CustomerID&lt;/p&gt;
&lt;p&gt;							 select o&lt;/p&gt;
&lt;p&gt;				}));&lt;/p&gt;
&lt;p&gt;	for (int i = 0; i &amp;lt; reps; ++i)&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		var q = cq.Invoke(nwdc);&lt;/p&gt;
&lt;p&gt;		foreach (var a in q)&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			total += a.Orders.Count();&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	stopwatch.Stop();&lt;/p&gt;
&lt;p&gt;	Trace.WriteLine(String.Format(&amp;quot;{0} {1} ({2} ticks)&amp;quot;, reps, stopwatch.Elapsed, stopwatch.ElapsedTicks));&lt;/p&gt;
&lt;p&gt;	return total;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;A similar query on a different database produced results that showed compiled was slower than uncompiled up to about 15 reps.&lt;/p&gt;
&lt;p&gt;So, it really depends on the query and the database.&lt;/p&gt;
&lt;p&gt;As with any optimizations, it should be checked to make sure it really is an optimization and that it's worth doing...&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7110708</link><pubDate>Mon, 14 Jan 2008 22:09:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7110708</guid><dc:creator>ricom</dc:creator><description>&lt;P&gt;Peter correctly points out that if you're bringing back lots of data (as in his second example) all this query compilation stuff just so much noise. &amp;nbsp;The real cost is in processing the data and creating the objects. &lt;/P&gt;
&lt;P&gt;With that much data coming back, compilation isn't hurting but it sure isn't helping much. Pretty much you've got the raw time to read the data and create the objects and that's it. &amp;nbsp;Which is as it should be :)&lt;/P&gt;
&lt;P&gt;I'm guessing now but I think the primary difference between my results and Peter's (where we were using the same query) is that I put in a dummy run to eliminate the cost of jitting and the cost of getting the database connection pool set up from the experiment.&amp;nbsp; Also I keep the total work constant so that I never have to measure any small times.&lt;/P&gt;</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7111356</link><pubDate>Mon, 14 Jan 2008 23:30:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7111356</guid><dc:creator>Anonymouse</dc:creator><description>&lt;p&gt;I was right, but in some sense I cheated. :P&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7111433</link><pubDate>Mon, 14 Jan 2008 23:42:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7111433</guid><dc:creator>Peter Ritchie</dc:creator><description>&lt;p&gt;Yes, I didn't perform and dummy runs to eliminate jitting in the metrics. &amp;nbsp;Unless I'm NGENing a product I like to see &amp;quot;worst&amp;quot; case. &amp;nbsp;If the user runs the application for the first time and it is prohibitively slow, they're not going to want to use it again :-). &amp;nbsp;But, metrics not including JIT times are equally as informative.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7112623</link><pubDate>Tue, 15 Jan 2008 01:53:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7112623</guid><dc:creator>Chabster</dc:creator><description>&lt;p&gt;using System;&lt;/p&gt;
&lt;p&gt;using System.Collections.Generic;&lt;/p&gt;
&lt;p&gt;using System.Linq;&lt;/p&gt;
&lt;p&gt;using System.Text;&lt;/p&gt;
&lt;p&gt;using System.Data.Linq;&lt;/p&gt;
&lt;p&gt;using System.Diagnostics;&lt;/p&gt;
&lt;p&gt;using System.Linq.Expressions;&lt;/p&gt;
&lt;p&gt;namespace LINQPerf&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;	class Program&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		static void Main(string[] args) {&lt;/p&gt;
&lt;p&gt;			Stopwatch s, sAvg;&lt;/p&gt;
&lt;p&gt;			const int iterations = 10;&lt;/p&gt;
&lt;p&gt;			const int ordersToFetch = 10000;&lt;/p&gt;
&lt;p&gt;			Northwind nw;&lt;/p&gt;
&lt;p&gt;			nw = new Northwind(&amp;quot;Data Source=D:\\Development\\Projects\\C#\\LINQPerf\\LINQPerf\\Northwind.sdf&amp;quot;);&lt;/p&gt;
&lt;p&gt;			//nw.Log = Console.Out;&lt;/p&gt;
&lt;p&gt;			nw.ObjectTrackingEnabled = false;&lt;/p&gt;
&lt;p&gt;			//s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			//var cacheQuery = from orders in nw.Orders select orders;			&lt;/p&gt;
&lt;p&gt;			//cacheQuery.Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;			//Console.WriteLine(&amp;quot;Cache: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;			s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			(from o in nw.Orders select new { OrderID_N = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;			Console.WriteLine(&amp;quot;Non compiled: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;			Console.WriteLine();&lt;/p&gt;
&lt;p&gt;			sAvg = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			{&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_1 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 1: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_2 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 2: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_3 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 3: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_4 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 4: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_5 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 5: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_6 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 6: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_7 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 7: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_8 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 8: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_9 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Non compiled 9: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;			}&lt;/p&gt;
&lt;p&gt;			Console.WriteLine(&amp;quot;Non compiled avg not in loop: &amp;quot; + ((double)sAvg.ElapsedMilliseconds / 10));&lt;/p&gt;
&lt;p&gt;			s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			for (int i = 0; i &amp;lt; iterations; i++) {&lt;/p&gt;
&lt;p&gt;				(from o in nw.Orders select new { OrderID_N_AVG = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch).GetEnumerator();&lt;/p&gt;
&lt;p&gt;			}&lt;/p&gt;
&lt;p&gt;			Console.WriteLine(&amp;quot;Non compiled avg in loop: &amp;quot; + ((double)s.ElapsedMilliseconds / iterations));&lt;/p&gt;
&lt;p&gt;			Console.WriteLine();&lt;/p&gt;
&lt;p&gt;			//s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			var compiledQuery = CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch));&lt;/p&gt;
&lt;p&gt;			//Console.WriteLine(&amp;quot;Compile: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;			//Console.WriteLine();&lt;/p&gt;
&lt;p&gt;			s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;			Console.WriteLine(&amp;quot;Compiled 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;			Console.WriteLine();&lt;/p&gt;
&lt;p&gt;			sAvg = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			{&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 1: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 2: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 3: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 4: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 5: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 6: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 7: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 8: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 9: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;			}&lt;/p&gt;
&lt;p&gt;			Console.WriteLine(&amp;quot;Compiled avg not in loop: &amp;quot; + ((double)sAvg.ElapsedMilliseconds / 10));&lt;/p&gt;
&lt;p&gt;			s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			for (int i = 0; i &amp;lt; iterations; i++) {&lt;/p&gt;
&lt;p&gt;				compiledQuery(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;			}&lt;/p&gt;
&lt;p&gt;			Console.WriteLine(&amp;quot;Compiled avg in loop: &amp;quot; + ((double)s.ElapsedMilliseconds / iterations));&lt;/p&gt;
&lt;p&gt;			Console.WriteLine();&lt;/p&gt;
&lt;p&gt;			sAvg = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;			{&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_0_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 0 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_1_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 1 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_2_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 2 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_3_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 3 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_4_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 4 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_5_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 5 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_6_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 6 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_7_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 7 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_8_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 8 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;				s = Stopwatch.StartNew();&lt;/p&gt;
&lt;p&gt;				CompiledQuery.Compile((Northwind nwDb) =&amp;gt; (from o in nwDb.Orders select new { OrderID_C_9_0 = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, ShippedDate = o.ShippedDate }).Take(ordersToFetch))(nw).GetEnumerator();&lt;/p&gt;
&lt;p&gt;				Console.WriteLine(&amp;quot;Compiled 9 0: &amp;quot; + s.ElapsedMilliseconds);&lt;/p&gt;
&lt;p&gt;			}&lt;/p&gt;
&lt;p&gt;			Console.WriteLine(&amp;quot;Compiled 0-9 avg not in loop: &amp;quot; + ((double)sAvg.ElapsedMilliseconds / 10));&lt;/p&gt;
&lt;p&gt;			Console.ReadLine();&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Result:&lt;/p&gt;
&lt;p&gt;Non compiled: 482&lt;/p&gt;
&lt;p&gt;Non compiled 0: 31&lt;/p&gt;
&lt;p&gt;Non compiled 1: 16&lt;/p&gt;
&lt;p&gt;Non compiled 2: 12&lt;/p&gt;
&lt;p&gt;Non compiled 3: 12&lt;/p&gt;
&lt;p&gt;Non compiled 4: 12&lt;/p&gt;
&lt;p&gt;Non compiled 5: 12&lt;/p&gt;
&lt;p&gt;Non compiled 6: 16&lt;/p&gt;
&lt;p&gt;Non compiled 7: 12&lt;/p&gt;
&lt;p&gt;Non compiled 8: 12&lt;/p&gt;
&lt;p&gt;Non compiled 9: 12&lt;/p&gt;
&lt;p&gt;Non compiled avg not in loop: 15,2&lt;/p&gt;
&lt;p&gt;Non compiled avg in loop: 9,6&lt;/p&gt;
&lt;p&gt;Compiled 0: 19&lt;/p&gt;
&lt;p&gt;Compiled 0: 6&lt;/p&gt;
&lt;p&gt;Compiled 1: 14&lt;/p&gt;
&lt;p&gt;Compiled 2: 6&lt;/p&gt;
&lt;p&gt;Compiled 3: 6&lt;/p&gt;
&lt;p&gt;Compiled 4: 6&lt;/p&gt;
&lt;p&gt;Compiled 5: 6&lt;/p&gt;
&lt;p&gt;Compiled 6: 6&lt;/p&gt;
&lt;p&gt;Compiled 7: 6&lt;/p&gt;
&lt;p&gt;Compiled 8: 6&lt;/p&gt;
&lt;p&gt;Compiled 9: 6&lt;/p&gt;
&lt;p&gt;Compiled avg not in loop: 7,4&lt;/p&gt;
&lt;p&gt;Compiled avg in loop: 6,6&lt;/p&gt;
&lt;p&gt;Compiled 0 0: 13&lt;/p&gt;
&lt;p&gt;Compiled 1 0: 31&lt;/p&gt;
&lt;p&gt;Compiled 2 0: 12&lt;/p&gt;
&lt;p&gt;Compiled 3 0: 11&lt;/p&gt;
&lt;p&gt;Compiled 4 0: 12&lt;/p&gt;
&lt;p&gt;Compiled 5 0: 14&lt;/p&gt;
&lt;p&gt;Compiled 6 0: 12&lt;/p&gt;
&lt;p&gt;Compiled 7 0: 12&lt;/p&gt;
&lt;p&gt;Compiled 8 0: 12&lt;/p&gt;
&lt;p&gt;Compiled 9 0: 12&lt;/p&gt;
&lt;p&gt;Compiled 0-9 avg not in loop: 14,7&lt;/p&gt;
&lt;p&gt;Conclusion: compiled expressions are emitted on first run, but not within CompiledQuery.Compile method. Seems like compilation also affects data mapping.&lt;/p&gt;
</description></item><item><title>LINQ query versus compiled LINQ query</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7113834</link><pubDate>Tue, 15 Jan 2008 03:55:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7113834</guid><dc:creator>Blog</dc:creator><description>&lt;p&gt;LINQ query versus compiled LINQ query&lt;/p&gt;
</description></item><item><title>LINQ query versus compiled LINQ query</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7113850</link><pubDate>Tue, 15 Jan 2008 03:58:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7113850</guid><dc:creator>Pawel Pabich's blog</dc:creator><description>&lt;p&gt;LINQ query versus compiled LINQ query&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7114237</link><pubDate>Tue, 15 Jan 2008 04:46:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7114237</guid><dc:creator>bhrgunatha</dc:creator><description>&lt;p&gt;&amp;gt;&amp;gt; A similar query on a different database produced results that showed compiled was slower than uncompiled up to about 15 reps.&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt; So, it really depends on the query and the database.&lt;/p&gt;
&lt;p&gt;I took a course on Optimizing SQL Server several years ago and learned a very valuable lesson.&lt;/p&gt;
&lt;p&gt;The answer is ALWAYS &amp;quot;It depends&amp;quot;&lt;/p&gt;
&lt;p&gt;The general guideline though seems to be use a compiled query for smaller sets of data with moderate re-use. But always profile to check ;)&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7118772</link><pubDate>Tue, 15 Jan 2008 19:11:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118772</guid><dc:creator>mattwar</dc:creator><description>&lt;p&gt;Chabster, &lt;/p&gt;
&lt;p&gt;When you call GetEnumerator() on a query you are executing it but not reading any of the data. &amp;nbsp;As Rico points out, for large data sets, reading the data is most of the work.&lt;/p&gt;
</description></item><item><title>re: Performance Quiz #13 -- Linq to SQL compiled queries cost</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7119366</link><pubDate>Tue, 15 Jan 2008 21:41:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7119366</guid><dc:creator>Chabster</dc:creator><description>&lt;p&gt;mattwar,&lt;/p&gt;
&lt;p&gt;i don't want data to be read. Only make sure that the query is built and sent to db. But your point might have some value - perhaps compilation affect s mapping performance?&lt;/p&gt;
</description></item><item><title>Community Convergence XXXIX</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7180849</link><pubDate>Mon, 21 Jan 2008 09:52:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7180849</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;Welcome to the XXXIX issue of Community Convergence. The big news this week is that Microsoft has begun&lt;/p&gt;</description></item><item><title>Community Convergence XXXIX</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#7298776</link><pubDate>Tue, 29 Jan 2008 08:23:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7298776</guid><dc:creator>Charlie Calvert's Community Blog</dc:creator><description>&lt;p&gt;Welcome to the XXXIX issue of Community Convergence. The big news this week is that Microsoft has begun&lt;/p&gt;</description></item><item><title>Linq Compiled Queries Q&amp;A</title><link>http://blogs.msdn.com/ricom/archive/2008/01/11/performance-quiz-13-linq-to-sql-compiled-queries-cost.aspx#8894806</link><pubDate>Mon, 25 Aug 2008 22:22:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8894806</guid><dc:creator>Rico Mariani's Performance Tidbits</dc:creator><description>&lt;p&gt;I did a series of postings on Linq Compiled Queries last year, I recently got some questions on those&lt;/p&gt;
</description></item></channel></rss>