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

$sort should be pushed before $lookup when is possible

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 4.4.4
    • 5.0.0-rc0
    • None
    • Fully Compatible
    • Query Optimization 2021-03-22, Query Optimization 2021-04-05

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

      Attachments

        Issue Links

          Activity

            People

              yuhong.zhang@mongodb.com Yuhong Zhang
              renato.riccio@mongodb.com Renato Riccio
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: