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

mongodb3.4 upgrade 4.2, query plan isMultiKey attributes change

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • ALL

    Description

      table like this: 

      insert command:
      db.getCollection("teachers").insert(

      { _id: ObjectId("6124cd389c7200001a000cb9"), name: "jack", students: [ 1, 2, 3 ] }

      );
      db.getCollection("teachers").insert(

      { _id: ObjectId("616e9d3aad1100002b002009"), name: "marray", students: [ ] }

      );

      *In mongodb 4.2*
      using index:
      db.teachers.createIndex(

      { "students.0": 1 }

      ,

      { name: "IX_first_student", }

      );

      query:
      db.teachers.find({"students.0": 1}).explain();

      result:
      {
      plannerVersion: NumberInt("1"),
      namespace: "myscrm_kktyadmin.teachers",
      indexFilterSet: false,
      parsedQuery: {
      "students.0":

      { $eq: 1 }

      },
      queryHash: "6ECDFB50",
      planCacheKey: "88E51EB0",
      winningPlan: {
      stage: "FETCH",
      inputStage: {
      stage: "IXSCAN",
      keyPattern:

      { "students.0": 1 }

      ,
      indexName: "IX_first_student",
      isMultiKey: true,
      multiKeyPaths:

      { "students.0": [ "students" ] }

      ,
      isUnique: false,
      isSparse: false,
      isPartial: false,
      indexVersion: NumberInt("2"),
      direction: "forward",
      indexBounds:

      { "students.0": [ "[1.0, 1.0]" ] }

      }
      },
      rejectedPlans: [ ]
      }

      *mongodb3.4*
      using index:
      db.teachers.createIndex(

      { "students.0": 1 }

      ,

      { name: "IX_first_student", }

      );

      query:
      db.teachers.find({"students.0": 1}).explain();

      result:
      {
      plannerVersion: NumberInt("1"),
      namespace: "myscrm_kktyadmin.teachers",
      indexFilterSet: false,
      parsedQuery: {
      "students.0":

      { $eq: 1 }

      },
      winningPlan: {
      stage: "FETCH",
      inputStage: {
      stage: "IXSCAN",
      keyPattern:

      { "students.0": 1 }

      ,
      indexName: "IX_first_student",
      isMultiKey: false,
      multiKeyPaths:

      { "students.0": [ ] }

      ,
      isUnique: false,
      isSparse: false,
      isPartial: false,
      indexVersion: NumberInt("2"),
      direction: "forward",
      indexBounds:

      { "students.0": [ "[1.0, 1.0]" ] }

      }
      },
      rejectedPlans: [ ]
      }

      question is why in mongodb 4.2 isMultiKey is true?

      in mongodb 4.2, this behavior make some query can't hint index, plz help.

      Attachments

        Activity

          People

            edwin.zhou@mongodb.com Edwin Zhou
            jcs12311@gmail.com 杰城 施
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: