[SERVER-50897] Fix Sort/Limit/Sort Optimization Created: 11/Sep/20  Updated: 29/Oct/23  Resolved: 26/Sep/20

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

Type: Task Priority: Major - P3
Reporter: Eric Cox (Inactive) Assignee: Eric Cox (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
is caused by SERVER-33966 redundant $sort in aggregation preven... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.7, v4.4
Participants:
Linked BF Score: 7

 Description   

A Fix for BF-18611. The gist here is that we need to be more careful when coalescing adjacent sorts. We can't simply optimize away the leading sort. We need to check if there is a limit stage in-between the adjacent sorts before deciding to optimize. If the sort key patterns are the same, then we can optimize the leading sort away, otherwise it's incorrect to merge the two sorts and take the min of a current limit and an adjacent limit.



 Comments   
Comment by Githook User [ 23/Oct/20 ]

Author:

{'name': 'Eric Cox', 'email': 'eric.cox@mongodb.com', 'username': 'ericox'}

Message: SERVER-50897 Fix Sort/Limit/Sort optimization

(cherry picked from commit d54f13fe76a8a9be411966ecdbf840c520d43833)
Branch: v4.4
https://github.com/mongodb/mongo/commit/5f66c3fa2af530e5f9242758eef87846d564fe96

Comment by Githook User [ 25/Sep/20 ]

Author:

{'name': 'Eric Cox', 'email': 'eric.cox@mongodb.com', 'username': 'ericox'}

Message: SERVER-50897 Fix Sort/Limit/Sort optimization
Branch: master
https://github.com/mongodb/mongo/commit/d54f13fe76a8a9be411966ecdbf840c520d43833

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