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

a problem about covering a index

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical - P2 Critical - P2
    • None
    • None
    • None
    • None
    • ALL

    Description

      i read the document about index of Mongodb.
      It says:
      An index covers (page 324) a query, a covered query, when:
      • all the fields in the query (page 42) are part of that index, and
      • all the fields returned in the documents that match the query are in the same index

      but i ensure an index on one field, and can cover the index with the following query:
      1) db.sb.ensureIndex(

      {'wei':1}

      )
      2) db.sb.find(

      {'wei':'www','name':'wu'}

      ).explain()
      {
      "cursor" : "BtreeCursor wei_1",
      "isMultiKey" : false,
      "n" : 1,
      "nscannedObjects" : 1,
      "nscanned" : 1,
      "nscannedObjectsAllPlans" : 2,
      "nscannedAllPlans" : 2,
      "scanAndOrder" : false,
      "indexOnly" : false,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "millis" : 0,
      "indexBounds" :

      { "wei" : [ [ "www", "www" ] ] }

      ,
      "server" : "srv03.lan.sankuai.com:27017"
      }
      the explain show the index is covered.
      anyone tell me why?

      Attachments

        Activity

          People

            Unassigned Unassigned
            chaoren316699 Chao Wei
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: