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

Query on same field with $gt/$gte and $lt/$lte ignores one end of the range

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.5
    • Component/s: Querying
    • Labels:
      None
    • Environment:
      RHEL
    • ALL

      db.Example.find({ $and: [

      { lc: "eng" }

      , { wordCount:

      { $gte: 4 }

      }, { wordCount:

      { $lte: 5 }

      }, { $or: [

      { group: "transmachina" }

      ,

      { group: "all" }

      ] },

      {pattern: false}

      , { "indices.textLc":

      { $in: [ "plain text", "plain", "text" ] }

      } ] }).explain();

      gives

      {
      "cursor" : "BtreeCursor indices.textLc_1_group_1_lc_1_wordCount_1_pattern_1_clExists_1 multi",
      "nscanned" : 7571,
      "nscannedObjects" : 7513,
      "n" : 97,
      "millis" : 78429,
      "nYields" : 1143,
      "nChunkSkips" : 0,
      "isMultiKey" : true,
      "indexOnly" : false,
      "indexBounds" : {
      "indices.textLc" : [
      [
      "plain",
      "plain"
      ],
      [
      "plain text",
      "plain text"
      ],
      [
      "text",
      "text"
      ]
      ],
      "group" : [
      [

      { "$minElement" : 1 }

      ,

      { "$maxElement" : 1 }

      ]
      ],
      "lc" : [
      [
      "eng",
      "eng"
      ]
      ],
      "wordCount" : [
      [
      4,
      1.7976931348623157e+308
      ]
      ],
      "pattern" : [
      [
      false,
      false
      ]
      ],
      "clExists" : [
      [

      { "$minElement" : 1 }

      ,

      { "$maxElement" : 1 }

      ]
      ]
      }
      }

      Note that the limit { wordCount:

      { $lte: 5 }

      } is ignored and thousands of objects are scanned needlessly

            Assignee:
            Unassigned Unassigned
            Reporter:
            niccottrell Nic Cottrell (Personal)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: