title: How to do mongodb queries faster?
body: <p>I have lots of queries like sample1,sample2 and sample3. There are more than 13 million records in mongodb collection. So this query getting long time. Is there any way to faster this query?</p>
  
  <p>I think using IMongoQuery object to resolve this problem. Is there any better way?</p>
  
  <p>Sample 1:</p>
  
  <pre><code>var collection = new MongoDbRepo().DbCollection&lt;Model&gt;("tblmodel");
  decimal total1 = collection.FindAll()
                  .SelectMany(x =&gt; x.MMB.MVD)
                  .Where(x =&gt; x.M01.ToLower() == "try")
                  .Sum(x =&gt; x.M06);
  </code></pre>
  
  <p>Sample 2:</p>
  
  <pre><code>var collection = new MongoDbRepo().DbCollection&lt;Model&gt;("tblmodel");
  decimal total2 = collection.FindAll().Sum(x =&gt; x.MMB.MVO.O01);
  </code></pre>
  
  <p>Sample 3:</p>
  
  <pre><code>var list1= collection.FindAll()
                       .SelectMany(x =&gt; x.MHB.VLH)
                       .Where(x =&gt; x.V15 &gt; 1).ToList();
  
  var list2= list1.GroupBy(x =&gt; new { x.H03, x.H09 })
                           .Select(lg =&gt;
                                 new
                                 {
                                     Prop1= lg.Key.H03,
                                     Prop2= lg.Count(),
                                     Prop3= lg.Sum(w =&gt; w.H09),
                                 });
  </code></pre>