-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
Query Optimization
-
ALL
-
(copied to CRM)
-
None
-
None
-
None
-
None
-
None
-
None
-
None
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
}
>