Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-34331

_id query not covered by index if $hint not specified

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • 3.6.3
    • Performance, Querying
    • None
    • ALL

    Description

      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?

      Attachments

        Activity

          People

            asya.kamsky@mongodb.com Asya Kamsky
            rmsmith Richard Smith
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: