<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Emad Ibrahim - Latest Comments in Improve LINQ Query Performance</title><link>http://emadibrahim.disqus.com/</link><description></description><atom:link href="https://emadibrahim.disqus.com/improve_linq_query_performance/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 17 Apr 2009 16:35:21 -0000</lastBuildDate><item><title>Re: Improve LINQ Query Performance</title><link>http://www.emadibrahim.com/2008/02/19/improve-linq-query-performance/#comment-8306050</link><description>&lt;p&gt;Essentially what you were looking for here was the difference of two collections (myTasks and outlookTasks). Enumerable has a built in method (Except()) to handle these when the collections are of the same type, and LINQ adds the ability to pass in a query to the "Except" method so that you can transform one collection before it is used.&lt;/p&gt;&lt;p&gt;Your first approach was O(N^2), iterating over one collection then iterating over the second collection once for each iteration of the first collection.&lt;/p&gt;&lt;p&gt;Your second approach is better: O(N) + O(N), which will iterate through collection one, then collection 2. However as the collections get bigger this will begin to take longer, which an optimized intersect algorithm can help you to avoid!&lt;/p&gt;&lt;p&gt;if you instead used:&lt;/p&gt;&lt;p&gt;Dim results = _&lt;br&gt;        myTasks.Except(From outlookTask In outlookTasks _&lt;br&gt;                                           Select outlookTask.Subject)&lt;/p&gt;&lt;p&gt;which I believe is implemented as O(N log N) which should nicely plateau and provide reliable performance even as the collections get larger, not to mention fewer lines of code!&lt;/p&gt;&lt;p&gt;Hope this helped!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">fdumlao</dc:creator><pubDate>Fri, 17 Apr 2009 16:35:21 -0000</pubDate></item><item><title>Re: Improve LINQ Query Performance</title><link>http://www.emadibrahim.com/2008/02/19/improve-linq-query-performance/#comment-1601668</link><description>&lt;p&gt;Ed, thanks for the tip, I will give it a shot and report back.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Emad Ibrahim</dc:creator><pubDate>Thu, 06 Mar 2008 10:08:58 -0000</pubDate></item><item><title>Re: Improve LINQ Query Performance</title><link>http://www.emadibrahim.com/2008/02/19/improve-linq-query-performance/#comment-1601667</link><description>&lt;p&gt;I'm wondering Emad, have you considered optimizing using the new GetTable method on the folder class?&lt;/p&gt;&lt;p&gt;Ed&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ed Richard</dc:creator><pubDate>Thu, 06 Mar 2008 05:05:42 -0000</pubDate></item></channel></rss>