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

The "isMultiKey" value is not correct in the output of aggregation explain plan

    • ALL
    • Hide
      > db.version()
      2.6.5
      > db.test.insert({x:1, y:[2,3]})
      WriteResult({ "nInserted" : 1 })
      > db.test.ensureIndex({y:1})
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.test.find({y:2}).explain()
      {
      	"cursor" : "BtreeCursor y_1",
      	"isMultiKey" : true,
      	"n" : 1,
      	"nscannedObjects" : 1,
      	"nscanned" : 1,
      	"nscannedObjectsAllPlans" : 1,
      	"nscannedAllPlans" : 1,
      	"scanAndOrder" : false,
      	"indexOnly" : false,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 0,
      	"indexBounds" : {
      		"y" : [
      			[
      				2,
      				2
      			]
      		]
      	},
      	"server" : "LindaQins-MacBook-Pro.local:22222",
      	"filterSet" : false
      }
      > db.test.aggregate([{$match:{y:2}}], {explain:true})
      {
      	"stages" : [
      		{
      			"$cursor" : {
      				"query" : {
      					"y" : 2
      				},
      				"plan" : {
      					"cursor" : "BtreeCursor ",
      					"isMultiKey" : false,
      					"scanAndOrder" : false,
      					"indexBounds" : {
      						"y" : [
      							[
      								2,
      								2
      							]
      						]
      					},
      					"allPlans" : [
      						{
      							"cursor" : "BtreeCursor ",
      							"isMultiKey" : false,
      							"scanAndOrder" : false,
      							"indexBounds" : {
      								"y" : [
      									[
      										2,
      										2
      									]
      								]
      							}
      						}
      					]
      				}
      			}
      		}
      	],
      	"ok" : 1
      }
      
      Show
      > db.version() 2.6.5 > db.test.insert({x:1, y:[2,3]}) WriteResult({ "nInserted" : 1 }) > db.test.ensureIndex({y:1}) { "createdCollectionAutomatically" : false , "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.test.find({y:2}).explain() { "cursor" : "BtreeCursor y_1" , "isMultiKey" : true , "n" : 1, "nscannedObjects" : 1, "nscanned" : 1, "nscannedObjectsAllPlans" : 1, "nscannedAllPlans" : 1, "scanAndOrder" : false , "indexOnly" : false , "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { "y" : [ [ 2, 2 ] ] }, "server" : "LindaQins-MacBook-Pro.local:22222" , "filterSet" : false } > db.test.aggregate([{$match:{y:2}}], {explain: true }) { "stages" : [ { "$cursor" : { "query" : { "y" : 2 }, "plan" : { "cursor" : "BtreeCursor " , "isMultiKey" : false , "scanAndOrder" : false , "indexBounds" : { "y" : [ [ 2, 2 ] ] }, "allPlans" : [ { "cursor" : "BtreeCursor " , "isMultiKey" : false , "scanAndOrder" : false , "indexBounds" : { "y" : [ [ 2, 2 ] ] } } ] } } } ], "ok" : 1 }

      The $match aggregation pipeline uses a multikey index, however, "isMultiKey" is false in the output of aggregation explain plan.

      Also, the index being used ("y_1") is missing in the field ("cursor" : "BtreeCursor "). It would be nice if the output can be ("cursor" : "BtreeCursor y_1").

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            linda.qin@mongodb.com Linda Qin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: