Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
2.0.1
-
None
-
ALL
Description
This is related to http://groups.google.com/group/mongodb-user/browse_thread/thread/9f08de0b3c3e1a13
Explain shows correct bounds for a query on an array of documents if the array only includes one document:
PRIMARY> db.foo.ensureIndex({'aH.s': 1, 'aH.m': 1, 'aH.u': 1})
|
PRIMARY> db.foo.insert({aH: [{s: 'a', m: 'b', u: 'c'}]})
|
PRIMARY> db.foo.find({'aH.s': 'x', 'aH.m': 'y', 'aH.u': 'z'}).explain()
|
{
|
"cursor" : "BtreeCursor aH.s_1_aH.m_1_aH.u_1",
|
"nscanned" : 0,
|
"nscannedObjects" : 0,
|
"n" : 0,
|
"millis" : 0,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"isMultiKey" : false,
|
"indexOnly" : false,
|
"indexBounds" : {
|
"aH.s" : [
|
[
|
"x",
|
"x"
|
]
|
],
|
"aH.m" : [
|
[
|
"y",
|
"y"
|
]
|
],
|
"aH.u" : [
|
[
|
"z",
|
"z"
|
]
|
]
|
}
|
}
|
If you then insert another document that has more than one document in the array the bounds listed by explain seem wrong:
PRIMARY> db.foo.insert({aH: [{s: 'd', m: 'e', u: 'f'}, {s: 'g', m: 'h', u: 'i'}]})
|
PRIMARY> db.foo.find({'aH.s': 'x', 'aH.m': 'y', 'aH.u': 'z'}).explain()
|
{
|
"cursor" : "BtreeCursor aH.s_1_aH.m_1_aH.u_1",
|
"nscanned" : 0,
|
"nscannedObjects" : 0,
|
"n" : 0,
|
"millis" : 0,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"isMultiKey" : true,
|
"indexOnly" : false,
|
"indexBounds" : {
|
"aH.s" : [
|
[
|
"x",
|
"x"
|
]
|
],
|
"aH.m" : [
|
[
|
{
|
"$minElement" : 1
|
},
|
{
|
"$maxElement" : 1
|
}
|
]
|
],
|
"aH.u" : [
|
[
|
{
|
"$minElement" : 1
|
},
|
{
|
"$maxElement" : 1
|
}
|
]
|
]
|
}
|
}
|