title: Fastest c# Linq query for drop down
body: <p>I'm looking to perform the fastest possible drop down query that will poll a database via the internet returning json.  The code snippet is an c# MVC controller that gets called by a Jquery Ajax function.  I'm looking to find out if anyone has any ideas to improve performance.  There could be over 50,000 customer records.</p>
  
  <p>Here is my MVC controller which is called every keypress that happens on the client.</p>
  
  <pre><code>//Load Customers as typing
  public ActionResult DropDownLoader(string SearchText, int MaxResults)
  {
      NovaDB db = new NovaDB((string)Session["DbConnection"]);
  
      var search1 = (from c in db.Customers
                     where c.Name.StartsWith(SearchText) || c.Street.StartsWith(SearchText) &amp;&amp; c.Fresh == false
                     select new { XID = c.ID, Line1 = c.Name, Line2 = c.Street, Line3 = c.City + ", " + c.State + "  " + c.Zip, Search = 1 });
      var search2 = (from c in db.Customers
                      where c.Name.Contains(SearchText) || c.Street.Contains(SearchText) &amp;&amp; c.Fresh == false
                     select new { XID = c.ID, Line1 = c.Name, Line2 = c.Street, Line3 = c.City + ", " + c.State + "  " + c.Zip, Search = 2 });
  
      var results = search1.Union(search2).OrderBy(x =&gt; x.Search).Take(MaxResults).ToList();
  
      return Json(results, JsonRequestBehavior.AllowGet);
  }
  </code></pre>