Details
-
Improvement
-
Resolution: Done
-
Major - P3
-
None
-
1.6.3
-
Windows, Unix
-
Query
Description
I have a collection called PartOffer with a multikey called 'p'. Typical PartOffer looks like:
{title:"My offer", p:{carFuel:9023, engine:232}}
|
I created an index on p:
db.PartOffer.ensureIndex({p:1})
|
But when using dot notation to find all offers depending on a property inside p, then the index is not used:
> db.PartOffer.find({"p.carFuel":9086}).explain()
|
{
|
"cursor" : "BasicCursor",
|
"nscanned" : 65424,
|
"nscannedObjects" : 65424,
|
"n" : 1139,
|
"millis" : 126,
|
"indexBounds" : {
|
|
|
}
|
}
|
But when not using dot notation, the index is used:
> db.PartOffer.find({p:{carFuel:9086}}).explain()
|
{
|
"cursor" : "BtreeCursor p_1",
|
"nscanned" : 21,
|
"nscannedObjects" : 21,
|
"n" : 21,
|
"millis" : 0,
|
"indexBounds" : {
|
"p" : [
|
[
|
{
|
"carFuel" : 9086
|
},
|
{
|
"carFuel" : 9086
|
}
|
]
|
]
|
}
|
}
|