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

Support min/max with clustered $hint

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.2.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • Execution Team 2021-11-15, Execution Team 2021-11-29

      If we perform the following query, the results of the find().hint().min().max() query includes every record, instead of min inclusive and max exclusive like standard index behavior

      // suppose we have documents {_id: 0} .... {_id: 100} 
      ....,
      const cmd: {
              find: collName,
              min: {_id: 3},
              max: {_id: 4},
              hint: {_id: 1},
          },
      const explain = assert.commandWorked(coll.runCommand({explain: cmd}));
      // we expect the nReturned to be 1 (doc {_id: 3}), however, nReturned = 100
      

      This is because we bypass accounting for min() / max() if the hint matches the cluster key.

      While using $lt(e)/$gte in a filter already works with $hint, min/max is handled differently internally.

            Assignee:
            haley.connelly@mongodb.com Haley Connelly
            Reporter:
            haley.connelly@mongodb.com Haley Connelly
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: