title: Why does Mongo hint make a query run up to 10 times faster?
body: <p>If I run a mongo query from the shell with explain(), get the name of the index used and then run the same query again, but with hint() specifying the same index to be used - "millis" field from explain plan is decreased significantly </p>
  
  <p>for example</p>
  
  <p>no hint provided:</p>
  
  <pre><code>&gt;&gt;db.event.find({ "type" : "X", "active" : true, "timestamp" : { "$gte" : NumberLong("1317498259000") }, "count" : { "$gte" : 0 } }).limit(3).sort({"timestamp" : -1 }).explain();
  
  {
      "cursor" : "BtreeCursor my_super_index",
      "nscanned" : 599,
      "nscannedObjects" : 587,
      "n" : 3,
      "millis" : 24,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "isMultiKey" : true,
      "indexOnly" : false,
      "indexBounds" : { ... }
  } 
  </code></pre>
  
  <p>hint provided:</p>
  
  <pre><code>&gt;&gt;db.event.find({ "type" : "X", "active" : true, "timestamp" : { "$gte" : NumberLong("1317498259000") }, "count" : { "$gte" : 0 } }).limit(3).sort({"timestamp" : -1 }).hint("my_super_index").explain();
  
  {
      "cursor" : "BtreeCursor my_super_index",
      "nscanned" : 599,
      "nscannedObjects" : 587,
      "n" : 3,
      "millis" : 2,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "isMultiKey" : true,
      "indexOnly" : false,
      "indexBounds" : { ... }
  } 
  </code></pre>
  
  <p>The only difference is "millis" field</p>
  
  <p>Does anyone know why is that?</p>
  
  <p>UPDATE: "Selecting which index to use" doesn't explain it, because mongo, as far as I know, selects index for each X (100?) runs, so it should be as fast as with hint next (X-1) runs</p>