title: Exceptionally slow database response time on Linq query
body: <p>I have written what I thought to be a pretty solid Linq statement but this is getting 2 to 5 second wait times on execution. Does anybody have thoughts about how to speed this up?</p>
  
  <pre><code>            t.states = (from s in tmdb.tmZipCodes
                          where zips.Contains(s.ZipCode) &amp;&amp; s.tmLicensing.Required.Equals(true)
                          group s by new Licensing { 
                              stateCode = s.tmLicensing.StateCode,
                              stateName = s.tmLicensing.StateName,
                              FIPSCode = s.tmLicensing.FIPSCode,
                              required = (bool)s.tmLicensing.Required,
                              requirements = s.tmLicensing.Requirements,
                              canWorkWhen = s.tmLicensing.CanWorkWhen,
                              appProccesingTime = (int) s.tmLicensing.AppProcessingTime 
                          }
                              into state
                              select state.Key).ToList();
  </code></pre>
  
  <p>I've changed it to a two stage query which runs almost instantaneously by doing a distinct query to make my grouping work, but it seems to me that it is a little counter intuitive to have that run so much faster than a single query.</p>