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.
- is caused by
-
SERVER-33966 redundant $sort in aggregation prevents best $limit $sort consolidation
- Closed