> c.ensureIndex({a:1})
|
> c.find({a:{$gt:5}})
|
> c.find({a:{$gt:5}}).explain()
|
{
|
"cursor" : "BtreeCursor a_1",
|
"nscanned" : 0,
|
"nscannedObjects" : 0,
|
"n" : 0,
|
"millis" : 7,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"isMultiKey" : false,
|
"indexOnly" : false,
|
"indexBounds" : {
|
"a" : [
|
[
|
5,
|
1.7976931348623157e+308
|
]
|
]
|
}
|
}
|
> c.find({a:{$gte:5}}).explain()
|
{
|
"cursor" : "BtreeCursor a_1",
|
"nscanned" : 0,
|
"nscannedObjects" : 0,
|
"n" : 0,
|
"millis" : 0,
|
"nYields" : 0,
|
"nChunkSkips" : 0,
|
"isMultiKey" : false,
|
"indexOnly" : false,
|
"indexBounds" : {
|
"a" : [
|
[
|
5,
|
1.7976931348623157e+308
|
]
|
]
|
}
|
}
|
With an exclusive bound our btree scanning implementation can avoid scanning every key with a=5, while with an inclusive bound we must scan every key with a=5. However, there is no indication of this from the explain output. I usually mention that this is the case when doing new hire training, and recently it was raised specifically as a usability issue.
|