title: How to efficiently page batches of results with MongoDB
body: <p>I am using the below query on my MongoDB collection which is taking more than an hour to complete.</p>
  
  <pre><code>db.collection.find({language:"hi"}).sort({_id:-1}).skip(5000).limit(1)
  </code></pre>
  
  <p>I am trying to to get the results in a batch of 5000 to process in either ascending or descending order for documents with "hi" as a value in language field. So i am using this query in which i am skipping the processed documents every time by incrementing the "skip" value.</p>
  
  <p>The document count in this collection is just above 20 million.
  An index on the field "language" is already created.
  MongoDB Version i am using is 2.6.7</p>
  
  <p>Is there a more appropriate index for this query which can get the result faster?</p>