|
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.
|