-
Website
http://www.emadibrahim.com -
Original page
http://www.emadibrahim.com/2008/02/19/improve-linq-query-performance/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
danatkinson
1 comment · 1 points
-
Korayem
3 comments · 1 points
-
dukon21
1 comment · 1 points
-
Mladen Mihajlovic
1 comment · 1 points
-
Chad Myers
3 comments · 1 points
-
-
Popular Threads
-
Select Random Records Using Nhibernate
3 weeks ago · 4 comments
-
Select Random Records Using Nhibernate
Ed
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.
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!
if you instead used:
Dim results = _
myTasks.Except(From outlookTask In outlookTasks _
Select outlookTask.Subject)
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!
Hope this helped!