_id query not covered by index if $hint not specified

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Minor - P4
    • None
    • Affects Version/s: 3.6.3
    • Component/s: Performance, Querying
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      I'm using mongodb 3.6.3 and my queries are fully covered by the _id index, e.g.

      db.getCollection('inventory').find({ _id: "myid123"}, { _id: 1 })
      

      Checking executionStats, totalDocsExamined is 1.

      According to the executionStats, there is an IDHACK stage. If I manually specify the index to use

      db.getCollection('inventory').find({ _id: "foobar"}, { _id: 1 }).hint( { _id: 1 } ).explain('executionStats')
      

      I get an IDXSCAN stage instead and totalDocsExamined is 0. Is this desired behavior?

            Assignee:
            Asya Kamsky
            Reporter:
            Richard Smith
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: