Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5338

Strange results with identical but differently structured queries

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 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?

            Assignee:
            aaron Aaron Staple
            Reporter:
            niccottrell Nic Cottrell (Personal)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: