explain() for aggregations pulls from the plan cache

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 3.5.5
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • ALL
    • Hide

      Run the following four commands (the last command is repeated twice):

      db.test.createIndex({x:1})
      db.test.createIndex({y:1})
      db.test.explain().aggregate([{$match:{x:1,y:1}}])
      db.test.explain().aggregate([{$match:{x:1,y:1}}])
      

      Output of the second .explain() in 3.2.9 is:

      > db.test.explain().aggregate([{$match:{x:1,y:1}}])
      {
      	"waitedMS" : NumberLong(0),
      	"stages" : [
      		{
      			"$cursor" : {
      				"query" : {
      					"x" : 1,
      					"y" : 1
      				},
      				"queryPlanner" : {
      					"plannerVersion" : 1,
      					"namespace" : "test.test",
      					"indexFilterSet" : false,
      					"parsedQuery" : {
      						"$and" : [
      							{
      								"x" : {
      									"$eq" : 1
      								}
      							},
      							{
      								"y" : {
      									"$eq" : 1
      								}
      							}
      						]
      					},
      					"winningPlan" : {
      						"stage" : "CACHED_PLAN",
      						"inputStage" : {
      							"stage" : "FETCH",
      							"filter" : {
      								"x" : {
      									"$eq" : 1
      								}
      							},
      							"inputStage" : {
      								"stage" : "IXSCAN",
      								"keyPattern" : {
      									"y" : 1
      								},
      								"indexName" : "y_1",
      								"isMultiKey" : false,
      								"isUnique" : false,
      								"isSparse" : false,
      								"isPartial" : false,
      								"indexVersion" : 1,
      								"direction" : "forward",
      								"indexBounds" : {
      									"y" : [
      										"[1.0, 1.0]"
      									]
      								}
      							}
      						}
      					},
      					"rejectedPlans" : [ ]
      				}
      			}
      		}
      	],
      	"ok" : 1
      }
      
      Show
      Run the following four commands (the last command is repeated twice): db.test.createIndex({x:1}) db.test.createIndex({y:1}) db.test.explain().aggregate([{$match:{x:1,y:1}}]) db.test.explain().aggregate([{$match:{x:1,y:1}}]) Output of the second .explain() in 3.2.9 is: > db.test.explain().aggregate([{$match:{x:1,y:1}}]) { "waitedMS" : NumberLong(0), "stages" : [ { "$cursor" : { "query" : { "x" : 1, "y" : 1 }, "queryPlanner" : { "plannerVersion" : 1, "namespace" : "test.test", "indexFilterSet" : false, "parsedQuery" : { "$and" : [ { "x" : { "$eq" : 1 } }, { "y" : { "$eq" : 1 } } ] }, "winningPlan" : { "stage" : "CACHED_PLAN", "inputStage" : { "stage" : "FETCH", "filter" : { "x" : { "$eq" : 1 } }, "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "y" : 1 }, "indexName" : "y_1", "isMultiKey" : false, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 1, "direction" : "forward", "indexBounds" : { "y" : [ "[1.0, 1.0]" ] } } } }, "rejectedPlans" : [ ] } } } ], "ok" : 1 }
    • Query 2017-03-27
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Running an explain for an aggregation pipeline appears to get its output from the plan cache. This is evident by the fact that the first stage in the winning plan is CACHED_PLAN and there are no rejected plans. This seems contrary to documented behavior. This was observed on version 3.2.9 and 3.3.8.

            Assignee:
            Nicholas Zolnierz
            Reporter:
            Chris Harris
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: