[SERVER-54823] $sort should be pushed before $lookup when is possible Created: 26/Feb/21  Updated: 29/Oct/23  Resolved: 24/Mar/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4.4
Fix Version/s: 5.0.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Renato Riccio Assignee: Yuhong Zhang
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-55417 Conditionally reorder $sort and $look... Backlog
is related to SERVER-26442 Push $sort before $project and $addFi... Open
Backwards Compatibility: Fully Compatible
Sprint: Query Optimization 2021-03-22, Query Optimization 2021-04-05
Participants:

 Description   

$sort should be pushed before $lookup if we are sorting on the "left" collection:
E.g.

db.foo.aggregate([
       {$lookup: {from: "new", localField: "_id", foreignField: "_id", as: "list"}},
       {$sort: {b:1}}
])



 Comments   
Comment by Githook User [ 23/Mar/21 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'danielzhangyh@gmail.com', 'username': 'YuhongZhang98'}

Message: SERVER-54823 $sort should be pushed before $lookup when is possible
Branch: master
https://github.com/mongodb/mongo/commit/ed8f7878acb8ac25b453499dee2d8e42166a4522

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