-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
Query Optimization
-
(copied to CRM)
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Multikey arrays are used if you are querying for an array element as:
db.foo.find({path: 10}).explain()
{
"cursor" : "BtreeCursor path_1",
"nscanned" : 275271,
"nscannedObjects" : 275271,
"n" : 275271,
"millis" : 269,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" : {
"path" : [
[
10,
10
]
]
}
}
But if you want to specifically find an array element at a specific position, the array is not used:
db.foo.find({"path.0": 10}).explain()
{
"cursor" : "BasicCursor",
"nscanned" : 2194200,
"nscannedObjects" : 2194200,
"n" : 80466,
"millis" : 1685,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
}
}
This collection contains about 2.2 million documents with field "path" set to an array of 1 to 5 elements selected at random in range 0-50