$sort should be pushed before $lookup when is possible

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 5.0.0-rc0
    • Affects Version/s: 4.4.4
    • Component/s: None
    • Fully Compatible
    • Query Optimization 2021-03-22, Query Optimization 2021-04-05
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      $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}}
      ])
      

            Assignee:
            Yuhong Zhang
            Reporter:
            Renato Riccio
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: