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

Aggregation explain "cursor" field truncated

    • Fully Compatible
    • ALL

      Affects 2.6.x.

      When an aggregation explain is run on a cached plan, the server outputs a truncated value for the "cursor" field.

      > db.foo.drop()
      true
      > db.foo.ensureIndex({a:1})
      {
      	"createdCollectionAutomatically" : true,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.foo.ensureIndex({b:1})
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 2,
      	"numIndexesAfter" : 3,
      	"ok" : 1
      }
      > db.foo.insert({a:1,b:2})
      WriteResult({ "nInserted" : 1 })
      > db.foo.insert({a:1,b:2})
      WriteResult({ "nInserted" : 1 })
      > db.foo.insert({a:1,b:2})
      WriteResult({ "nInserted" : 1 })
      > db.foo.aggregate([{$match: {a:1,b:1}}]) // Caches plan.
      > db.foo.aggregate([{$match: {a:1,b:1}}],{explain:true})
      {
      	"stages" : [
      		{
      			"$cursor" : {
      				"query" : {
      					"a" : 1,
      					"b" : 1
      				},
      				"plan" : {
      					"cursor" : "BtreeCursor ", // INCORRECT
      					"isMultiKey" : false,
      					"scanAndOrder" : false,
      					"indexBounds" : {
      						"b" : [
      							[
      								1,
      								1
      							]
      						]
      					},
      					"allPlans" : [
      						{
      							"cursor" : "BtreeCursor ", // INCORRECT
      							"isMultiKey" : false,
      							"scanAndOrder" : false,
      							"indexBounds" : {
      								"b" : [
      									[
      										1,
      										1
      									]
      								]
      							}
      						}
      					]
      				}
      			}
      		}
      	],
      	"ok" : 1
      }
      >
      

      Aggregation queries with only one solution are affected, as well.

      > db.foo.aggregate([{$match: {a:1}}],{explain:true})
      {
      	"stages" : [
      		{
      			"$cursor" : {
      				"query" : {
      					"a" : 1
      				},
      				"plan" : {
      					"cursor" : "BtreeCursor ", // INCORRECT
      					"isMultiKey" : false,
      					"scanAndOrder" : false,
      					"indexBounds" : {
      						"a" : [
      							[
      								1,
      								1
      							]
      						]
      					},
      					"allPlans" : [
      						{
      							"cursor" : "BtreeCursor ", // INCORRECT
      							"isMultiKey" : false,
      							"scanAndOrder" : false,
      							"indexBounds" : {
      								"a" : [
      									[
      										1,
      										1
      									]
      								]
      							}
      						}
      					]
      				}
      			}
      		}
      	],
      	"ok" : 1
      }
      >
      

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            rassi J Rassi
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: