Database Reference
In-Depth Information
To confirm that the given index is being used, you can optionally add the explain()
function, returning information about the query plan chosen. Here, the indexBounds
value tells you about the index used:
> db.media.find( { ISBN: " 978-1-4302-5821-6"} ) . hint ( { ISBN: 1 }
).explain()
{
"cursor" : "BtreeCursor ISBN_1",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 1,
"nscanned" : 1,
"nscannedObjectsAllPlans" : 1,
"nscannedAllPlans" : 1,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
"ISBN" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
]
},
"server" : "localhost:27017"
}
Constraining Query Matches
The min() and max() functions enable you to constrain query matches to only those
that have index keys between the min and max keys specified. Therefore, you will need
to have an index for the keys you are specifying. Also, you can either combine the two
 
Search WWH ::




Custom Search