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

Conditionally reorder $sort and $lookup depending on whether the query planner allows for an index-provided sort

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None
    • Labels:

      Description

      With the pipeline of [$lookup, $unwind, $sort, $limit], the current implementation will not push $sort before $lookup since $unwind will block $limit from being pushed before $lookup and then combined with $sort. Although letting $sort take advantages of the indexes benefits more than absorbing $limit into $sort to run a top-k sort, there is no way in the current system to learn if there are indexes on the sorting fields.

      Instead of depending on the presence of $unwind, the optimization should reorder $lookup and $sort depending on if an index-provided sort is allowed. The other condition of not sorting on fields introduced or modified by $lookup and $unwind remains the same.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              yuhong.zhang Yuhong Zhang
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: