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

Explain output for queries that use subplanner does not include rejected plans

    • Query Optimization
    • ALL

      Explain for queries that use the query planner's subplanning mechanism (e.g. rooted $or queries) does not display rejected plans (see "rejectedPlans" : [ ] in the below example).

      This would require changing the explain output format to accommodate these queries, since the subplanner independently plans each branch of the OR clause.

      > 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.find({$or: [{a: 1, b: 1}, {a: 2, b: 2}]}).explain()
      {
      	"queryPlanner" : {
      		"plannerVersion" : 1,
      		"namespace" : "test.foo",
      		"indexFilterSet" : false,
      		"parsedQuery" : {
      			"$or" : [
      				{
      					"$and" : [
      						{
      							"a" : {
      								"$eq" : 1
      							}
      						},
      						{
      							"b" : {
      								"$eq" : 1
      							}
      						}
      					]
      				},
      				{
      					"$and" : [
      						{
      							"a" : {
      								"$eq" : 2
      							}
      						},
      						{
      							"b" : {
      								"$eq" : 2
      							}
      						}
      					]
      				}
      			]
      		},
      		"winningPlan" : {
      			"stage" : "SUBPLAN",
      			"inputStage" : {
      				"stage" : "KEEP_MUTATIONS",
      				"inputStage" : {
      					"stage" : "OR",
      					"inputStages" : [
      						{
      							"stage" : "FETCH",
      							"filter" : {
      								"a" : {
      									"$eq" : 1
      								}
      							},
      							"inputStage" : {
      								"stage" : "IXSCAN",
      								"keyPattern" : {
      									"b" : 1
      								},
      								"indexName" : "b_1",
      								"isMultiKey" : false,
      								"isUnique" : false,
      								"isSparse" : false,
      								"isPartial" : false,
      								"indexVersion" : 1,
      								"direction" : "forward",
      								"indexBounds" : {
      									"b" : [
      										"[1.0, 1.0]"
      									]
      								}
      							}
      						},
      						{
      							"stage" : "FETCH",
      							"filter" : {
      								"a" : {
      									"$eq" : 2
      								}
      							},
      							"inputStage" : {
      								"stage" : "IXSCAN",
      								"keyPattern" : {
      									"b" : 1
      								},
      								"indexName" : "b_1",
      								"isMultiKey" : false,
      								"isUnique" : false,
      								"isSparse" : false,
      								"isPartial" : false,
      								"indexVersion" : 1,
      								"direction" : "forward",
      								"indexBounds" : {
      									"b" : [
      										"[2.0, 2.0]"
      									]
      								}
      							}
      						}
      					]
      				}
      			}
      		},
      		"rejectedPlans" : [ ]
      	},
      	"serverInfo" : {
      		"host" : "rassi",
      		"port" : 27017,
      		"version" : "3.1.6-pre-",
      		"gitVersion" : "deb117ad90c9f7d5360c4d249997ccb842d8c5ed"
      	},
      	"ok" : 1
      }
      >
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            rassi J Rassi
            Votes:
            1 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated: