title: EF LINQ ToList is very slow
body: <p>I am using <code>ASP NET MVC</code> 4.5 and <code>EF6</code>, code first migrations.</p>
  
  <p>I have this code, which takes about 6 seconds.</p>
  
  <pre><code>var filtered = _repository.Requests.Where(r =&gt; some conditions); // this is fast, conditions match only 8 items
  var list = filtered.ToList(); // this takes 6 seconds, has 8 items inside
  </code></pre>
  
  <p>I thought that this is because of relations, it must build them inside memory, but that is not the case, <strong>because even when I return 0 fields, it is still as slow</strong>.</p>
  
  <pre><code>var filtered = _repository.Requests.Where(r =&gt; some conditions).Select(e =&gt; new {}); // this is fast, conditions match only 8 items
  var list = filtered.ToList(); // this takes still around 5-6 seconds, has 8 items inside
  </code></pre>
  
  <p>Now the Requests table is quite complex, lots of relations and has ~16k items. On the other hand, the filtered list should only contain proxies to 8 items.</p>
  
  <p>Why is <code>ToList()</code> method so slow? I actually think the problem is not in ToList() method, but probably EF issue, or bad design problem.</p>
  
  <p>Anyone has had experience with anything like this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>These are the conditions:</p>
  
  <pre><code>_repository.Requests.Where(r =&gt; ids.Any(a =&gt; a == r.Student.Id) &amp;&amp; r.StartDate &lt;= cycle.EndDate &amp;&amp; r.EndDate &gt;= cycle.StartDate)
  </code></pre>
  
  <p>So basically, I can checking if <code>Student</code> id is in my id list and checking if dates match.</p>