Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54823

$sort should be pushed before $lookup when is possible

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 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

      $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@mongodb.com Yuhong Zhang
            Reporter:
            renato.riccio@mongodb.com Renato Riccio
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: