-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.0.3
-
Component/s: Querying
-
None
I am tracking some slow queries and found some odd behavior. This query (generated by Morphia) scans 20k objects and correctly returns 22 objects:
db.Example.find({ $and: [
{ lc: "eng" }, { $or: [
{ group: "cn" },
{ group: "all" }] }, { "indices.textLc":
{ $in: [ "media strengthening", "strengthening", "media" ] }}, { wordCount:
{ $gte: 1 , $lte: 2 }} ] }).explain();
But it has this in the indexBounds: "wordCount" : [ [1,1.7976931348623157e+308]],
This other query has the same limits and gives the same 22 objects, but only scans 4k objects:
db.Example.find( {lc: "eng" , $or: [
{ group: "cn" },
{ group: "all" }], "indices.textLc":
{ $in: [ "media strengthening", "strengthening", "media" ] }, wordCount: { $gte: 1 , $lte: 2 }}).explain();
This explain gives the same unbound max wordCount, but is obviously much faster. Is this something that can be fixed in the server or do I need to restructure all my queries?
- duplicates
-
SERVER-3327 use indexes for nested $or clauses
- Closed