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

Generalize the $sort removal optimizations after $search/$vectorSearch/$mergeCursors

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration

      In the previous tickets SERVER-96059SERVER-96064, & SERVER-96065, optimizations were introduced in various cases that removed a redundant $sort stage. However, these optimizations only worked if the $sort stage came directly after the stage that sorted the documents.

       

      All these optimizations should be generalizable in the same way: if any number of stages are added between the sorting stage and the $sort that do not impact the sort order, the $sort should still be removable.

       

      Look at SERVER-96067 to understand how to determine if a stage in general is know to preserve sort order or not, within the optimization logic.

       

      Test coverage should be added to all these cases that adding stages that preserve sort order do not impact the ability to remove the $sort, and also that the opposite is true.

            Assignee:
            Unassigned Unassigned
            Reporter:
            joseph.shalabi@mongodb.com Joe Shalabi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: