Linq query performs poor according to performance analyzer in VS2012 I've a Linq query that performs poorly:

var minuteValues = ValuesInMemory.Where(o =&gt; o.Key.Day == tmpValue.QuoteDate.Day &amp;&amp;
                                  o.Key.Hour == tmpValue.QuoteDate.Hour &amp;&amp;
                                  o.Key.Minute == tmpValue.QuoteDate.Minute &amp;&amp;
                                  o.Key.Second &gt;= 0).Select(p =&gt; p.Value).ToList();


Is there a way to do this better?

private readonly ConcurrentDictionary&lt;DateTime, double&gt; ValuesInMemory = new ConcurrentDictionary&lt;DateTime, double&gt;();


ValuesInMemory holds about 6700 records 24/7. Every second records are added and every 2 hours the oldest values are stored in SQL Server. But the average amount of values is 6700.
I think the crux of your problem here is you are using the wrong tool for the job. The purpose of a dictionary is usually for direct retrieval i.e. give me the value associated with X key. I'm not sure how optimized they are for O(n) queries.

To rule out the ConcurrentDictionary&lt;TKey, TValue&gt; being the bottleneck, you could try switching it out for something like a ConcurrentBag&lt;T&gt;.