[SERVER-19350] Explain output for queries that use subplanner does not include rejected plans Created: 09/Jul/15  Updated: 17/May/23

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
Assigned Teams:
Query Execution
Operating System: ALL
Participants:
Case:

 Description   

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
}
>


Generated at Thu Feb 08 03:50:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.