Databases Reference
In-Depth Information
[
{
"username" : "sally",
"age" : 10
},
{
"username" : "sally",
"age" : 1.7976931348623157e+308
}
]
]
}
}
We are querying for an exact match on "username" and a range of values for "age" , so
the database chooses to use the {"username" : 1, "age" : 1} index, reversing the terms
of the query. If, on the other hand, we query for an exact age and a range of names,
MongoDB will use the other index:
> db.c.find({"age" : 14, "username" : /.*/}).explain()
{
"cursor" : "BtreeCursor age_1_username_1 multi",
"indexBounds" : [
[
{
"age" : 14,
"username" : ""
},
{
"age" : 14,
"username" : {
}
}
],
[
{
"age" : 14,
"username" : /.*/
},
{
"age" : 14,
"username" : /.*/
}
]
],
"nscanned" : 2,
"nscannedObjects" : 2,
"n" : 2,
"millis" : 2,
"allPlans" : [
{
"cursor" : "BtreeCursor age_1_username_1 multi",
"indexBounds" : [
[
 
Search WWH ::




Custom Search