Databases Reference
In-Depth Information
},
"name" : "age_1"
}
"allPlans" : [ ... ]
This key lists all of the plans MongoDB considered for the query. The choice here
was fairly obvious, because we had an index on "age" and we were querying for
"age" . If we had multiple overlapping indexes and a more complex query, "all
Plans" would contain information about all of the possible plans that could have
been used.
Let's take a slightly more complicated example: suppose you have an index on {"user
name" : 1, "age" : 1} and an index on {"age" : 1, "username" : 1} . What happens
if you query for username and age ? Well, it depends on the query:
> db.c.find({age : {$gt : 10}, username : "sally"}).explain()
{
"cursor" : "BtreeCursor username_1_age_1",
"indexBounds" : [
[
{
"username" : "sally",
"age" : 10
},
{
"username" : "sally",
"age" : 1.7976931348623157e+308
}
]
],
"nscanned" : 13,
"nscannedObjects" : 13,
"n" : 13,
"millis" : 5,
"allPlans" : [
{
"cursor" : "BtreeCursor username_1_age_1",
"indexBounds" : [
[
{
"username" : "sally",
"age" : 10
},
{
"username" : "sally",
"age" : 1.7976931348623157e+308
}
]
]
}
],
"oldPlan" : {
"cursor" : "BtreeCursor username_1_age_1",
"indexBounds" : [
 
Search WWH ::




Custom Search