title: MongoDB find query very slow even with index
body: <p>I don't understand why the following query is so slow, the explain shows it will take 74+ seconds to finish, in spite of the presence of index.</p>
  
  <p>both <code>dev_id</code> and <code>_id</code> are indexed I can assure you, it seems just not helpful at all.</p>
  
  <pre><code>db.DeviceLoginLog.find({"dev_id": "xxx"}).skip(0).limit(10).sort({"_id": -1}).explain("executionStats");
  
  </code></pre>
  
  <p>Can anyone help me to interpret explain output and advise me how to speed up?</p>
  
  <pre><code>{
          "queryPlanner" : {
                  "plannerVersion" : 1,
                  "namespace" : "example.DeviceLoginLog",
                  "indexFilterSet" : false,
                  "parsedQuery" : {
                          "dev_id" : {
                                  "$eq" : "xxx"
                          }
                  },
                  "winningPlan" : {
                          "stage" : "SORT",
                          "sortPattern" : {
                                  "_id" : -1
                          },
                          "limitAmount" : 10,
                          "inputStage" : {
                                  "stage" : "KEEP_MUTATIONS",
                                  "inputStage" : {
                                          "stage" : "FETCH",
                                          "inputStage" : {
                                                  "stage" : "IXSCAN",
                                                  "keyPattern" : {
                                                          "dev_id" : 1
                                                  },
                                                  "indexName" : "dev_id_1",
                                                  "isMultiKey" : false,
                                                  "direction" : "forward",
                                                  "indexBounds" : {
                                                          "dev_id" : [
                                                                  "[\"xxx\", \"xxx\"]"
                                                          ]
                                                  }
                                          }
                                  }
                          }
                  },
                  "rejectedPlans" : [
                          {
                                  "stage" : "LIMIT",
                                  "limitAmount" : 4,
                                  "inputStage" : {
                                          "stage" : "FETCH",
                                          "filter" : {
                                                  "dev_id" : {
                                                          "$eq" : "xxx"
                                                  }
                                          },
                                          "inputStage" : {
                                                  "stage" : "IXSCAN",
                                                  "keyPattern" : {
                                                          "_id" : 1
                                                  },
                                                  "indexName" : "_id_",
                                                  "isMultiKey" : false,
                                                  "direction" : "backward",
                                                  "indexBounds" : {
                                                          "_id" : [
                                                                  "[MaxKey, MinKey]"
                                                          ]
                                                  }
                                          }
                                  }
                          }
                  ]
          },
          "executionStats" : {
                  "executionSuccess" : true,
                  "nReturned" : 10,
                  "executionTimeMillis" : 74867,
                  "totalKeysExamined" : 9203,
                  "totalDocsExamined" : 9203,
                  "executionStages" : {
                          "stage" : "SORT",
                          "nReturned" : 10,
                          "executionTimeMillisEstimate" : 49860,
                          "works" : 9537,
                          "advanced" : 10,
                          "needTime" : 9204,
                          "needFetch" : 321,
                          "saveState" : 1864,
                          "restoreState" : 1864,
                          "isEOF" : 1,
                          "invalidates" : 1064,
                          "sortPattern" : {
                                  "_id" : -1
                          },
                          "memUsage" : 1890,
                          "memLimit" : 33554432,
                          "limitAmount" : 10,
                          "inputStage" : {
                                  "stage" : "KEEP_MUTATIONS",
                                  "nReturned" : 9203,
                                  "executionTimeMillisEstimate" : 49820,
                                  "works" : 9525,
                                  "advanced" : 9203,
                                  "needTime" : 0,
                                  "needFetch" : 321,
                                  "saveState" : 1864,
                                  "restoreState" : 1864,
                                  "isEOF" : 1,
                                  "invalidates" : 1064,
                                  "inputStage" : {
                                          "stage" : "FETCH",
                                          "nReturned" : 9203,
                                          "executionTimeMillisEstimate" : 49820,
                                          "works" : 9525,
                                          "advanced" : 9203,
                                          "needTime" : 0,
                                          "needFetch" : 321,
                                          "saveState" : 1864,
                                          "restoreState" : 1864,
                                          "isEOF" : 1,
                                          "invalidates" : 1064,
                                          "docsExamined" : 9203,
                                          "alreadyHasObj" : 0,
                                          "inputStage" : {
                                                  "stage" : "IXSCAN",
                                                  "nReturned" : 9203,
                                                  "executionTimeMillisEstimate" : 10,
                                                  "works" : 9204,
                                                  "advanced" : 9203,
                                                  "needTime" : 0,
                                                  "needFetch" : 0,
                                                  "saveState" : 1864,
                                                  "restoreState" : 1864,
                                                  "isEOF" : 1,
                                                  "invalidates" : 1064,
                                                  "keyPattern" : {
                                                          "dev_id" : 1
                                                  },
                                                  "indexName" : "dev_id_1",
                                                  "isMultiKey" : false,
                                                  "direction" : "forward",
                                                  "indexBounds" : {
                                                          "dev_id" : [
                                                                  "[\"xxx\", \"xxx\"]"
                                                          ]
                                                  },
                                                  "keysExamined" : 9203,
                                                  "dupsTested" : 0,
                                                  "dupsDropped" : 0,
                                                  "seenInvalidated" : 0,
                                                  "matchTested" : 0
                                          }
                                  }
                          }
                  }
          },
          "serverInfo" : {
                  "host" : "iZ231ear7c9Z",
                  "port" : 27017,
                  "version" : "3.0.3",
                  "gitVersion" : "b40106b36eecd1b4407eb1ad1af6bc60593c6105"
          },
          "ok" : 1
  }
  </code></pre>
  
  <p>Thanks in advance！</p>