Details
-
Bug
-
Resolution: Done
-
Major - P3
-
2.6.0-rc1
-
ALL
Description
Explain for indexed $or queries always incorrectly sets 'nscannedObjects' to zero, even when the query is not covered.
To reproduce:
> db.foo.ensureIndex({a:1})
|
> db.foo.ensureIndex({b:1})
|
> for(i=0;i<10;i++){db.foo.insert({a:1,b:1})} |
> db.foo.find({$or:[{a:1},{b:1}]}).explain().nscannedObjects
|
0 // should be 20 (well, arguably should be 10, but at least in 2.4.9 this is 20) |
Full explain output:
> db.foo.find({$or:[{a:1},{b:1}]}).explain(true)
|
{
|
"clauses" : [
|
{
|
"cursor" : "BtreeCursor a_1",
|
"isMultiKey" : false,
|
"n" : 10,
|
"nscannedObjects" : 0,
|
"nscanned" : 10,
|
"scanAndOrder" : false,
|
"indexOnly" : false,
|
"nChunkSkips" : 0,
|
"indexBounds" : {
|
"a" : [
|
[
|
1,
|
1
|
]
|
]
|
}
|
},
|
{
|
"cursor" : "BtreeCursor b_1",
|
"isMultiKey" : false,
|
"n" : 10,
|
"nscannedObjects" : 0,
|
"nscanned" : 10,
|
"scanAndOrder" : false,
|
"indexOnly" : false,
|
"nChunkSkips" : 0,
|
"indexBounds" : {
|
"b" : [
|
[
|
1,
|
1
|
]
|
]
|
}
|
}
|
],
|
"cursor" : "QueryOptimizerCursor",
|
"n" : 10,
|
"nscannedObjects" : 0,
|
"nscanned" : 20,
|
"nscannedObjectsAllPlans" : 0,
|
"nscannedAllPlans" : 20,
|
"scanAndOrder" : false,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"millis" : 1,
|
"allPlans" : [
|
{
|
"clauses" : [
|
{
|
"cursor" : "BtreeCursor a_1",
|
"isMultiKey" : false,
|
"n" : 10,
|
"nscannedObjects" : 0,
|
"nscanned" : 10,
|
"scanAndOrder" : false,
|
"indexOnly" : false,
|
"nChunkSkips" : 0,
|
"indexBounds" : {
|
"a" : [
|
[
|
1,
|
1
|
]
|
]
|
}
|
},
|
{
|
"cursor" : "BtreeCursor b_1",
|
"isMultiKey" : false,
|
"n" : 10,
|
"nscannedObjects" : 0,
|
"nscanned" : 10,
|
"scanAndOrder" : false,
|
"indexOnly" : false,
|
"nChunkSkips" : 0,
|
"indexBounds" : {
|
"b" : [
|
[
|
1,
|
1
|
]
|
]
|
}
|
}
|
],
|
"cursor" : "QueryOptimizerCursor",
|
"n" : 10,
|
"nscannedObjects" : 0,
|
"nscanned" : 20,
|
"scanAndOrder" : false,
|
"nChunkSkips" : 0
|
}
|
],
|
"server" : "Rassi-MacBook-Pro.local:27017",
|
"filterSet" : false,
|
"stats" : {
|
"type" : "FETCH",
|
"works" : 22,
|
"yields" : 0,
|
"unyields" : 0,
|
"invalidates" : 0,
|
"advanced" : 10,
|
"needTime" : 11,
|
"needFetch" : 0,
|
"isEOF" : 1,
|
"alreadyHasObj" : 0,
|
"forcedFetches" : 0,
|
"matchTested" : 0,
|
"children" : [
|
{
|
"type" : "OR",
|
"works" : 22,
|
"yields" : 0,
|
"unyields" : 0,
|
"invalidates" : 0,
|
"advanced" : 10,
|
"needTime" : 11,
|
"needFetch" : 0,
|
"isEOF" : 1,
|
"dupsTested" : 20,
|
"dupsDropped" : 10,
|
"locsForgotten" : 0,
|
"matchTested_0" : 0,
|
"matchTested_1" : 0,
|
"children" : [
|
{
|
"type" : "IXSCAN",
|
"works" : 11,
|
"yields" : 0,
|
"unyields" : 0,
|
"invalidates" : 0,
|
"advanced" : 10,
|
"needTime" : 0,
|
"needFetch" : 0,
|
"isEOF" : 1,
|
"keyPattern" : "{ a: 1.0 }",
|
"boundsVerbose" : "field #0['a']: [1.0, 1.0]",
|
"isMultiKey" : 0,
|
"yieldMovedCursor" : 0,
|
"dupsTested" : 0,
|
"dupsDropped" : 0,
|
"seenInvalidated" : 0,
|
"matchTested" : 0,
|
"keysExamined" : 10,
|
"children" : [ ]
|
},
|
{
|
"type" : "IXSCAN",
|
"works" : 11,
|
"yields" : 0,
|
"unyields" : 0,
|
"invalidates" : 0,
|
"advanced" : 10,
|
"needTime" : 0,
|
"needFetch" : 0,
|
"isEOF" : 1,
|
"keyPattern" : "{ b: 1.0 }",
|
"boundsVerbose" : "field #0['b']: [1.0, 1.0]",
|
"isMultiKey" : 0,
|
"yieldMovedCursor" : 0,
|
"dupsTested" : 0,
|
"dupsDropped" : 0,
|
"seenInvalidated" : 0,
|
"matchTested" : 0,
|
"keysExamined" : 10,
|
"children" : [ ]
|
}
|
]
|
}
|
]
|
}
|
}
|
>
|
Attachments
Issue Links
- related to
-
SERVER-12529 incorrect explain output for covered $or with new query framework
-
- Closed
-