-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.0.3
-
Component/s: Querying
-
None
-
Query Optimization
I was just tracking some slow queries and found queries like:
db.Example.find({ "indices.text":
{ $all: [ "le", "mois", "suivant" ] }, lc: "fra", group: "all" })
giving
{
"cursor" : "BtreeCursor indices.text_1_lc_1_group_1",
"nscanned" : 244471,
"nscannedObjects" : 244471,
"n" : 34,
"millis" : 6211,
"nYields" : 6,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" :
}
but
> db.Example.find({ "indices.text":
{ $all: [ "suivant", "le", "mois" ] }, lc: "fra", group: "all" }).explain();
{
"cursor" : "BtreeCursor indices.text_1_lc_1_group_1",
"nscanned" : 1948,
"nscannedObjects" : 1948,
"n" : 34,
"millis" : 102,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : true,
"indexOnly" : false,
"indexBounds" :
}
I can manually re-order my inputs to the $all putting longest strings first, but perhaps Mongo should have similar logic built in since longer strings should naturally be less common and therefore need less scanning?
- is related to
-
SERVER-1000 $all with query optimizer
- Closed