[SERVER-61374] Support min/max with clustered $hint Created: 10/Nov/21  Updated: 29/Oct/23  Resolved: 12/Nov/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0

Type: Task Priority: Major - P3
Reporter: Haley Connelly Assignee: Haley Connelly
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-60123 Support using clusterKey {_id : 1} fo... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2021-11-15, Execution Team 2021-11-29
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 12/Nov/21 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-61374 Support min/max with clustered hint
Branch: master
https://github.com/mongodb/mongo/commit/51afcebf31c00901a269edce636bcc401bd2b5de

Generated at Thu Feb 08 05:52:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.