title: how to optimize MongoDB find query for billion documents?
body: <p>Here is my collection which has more than 1 billion documents in it and each document has size of 2 KB</p>
  
  <pre><code>sample document
  {
      "sensor" : "temperature",
      "timestamp" : ISODate("2018-02-22T01:55:00Z"),
      ... some more key values
  }
  </code></pre>
  
  <p>I have index on key sensor and timestamp individualy
  Find query</p>
  
  <pre><code>db.collection.find({"sensor":"temperature", "timestamp":{"$gte":ISODate("2018-02-22T00:00:00Z"), 
                                            "$lt":ISODate("2018-02-23T00:00:00Z")}})
  </code></pre>
  
  <p>But it takes minutes to respond around more than 20-30 minutes which is not acceptable for my application. So what is the better way to optimize this query so it will results in less than 30 seconds (because mongoose will return timeout error if query is taking more than 30 seconds). Is there any solution for optimizing query except sharding?</p>