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

XMLWordPrintableJSON

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

      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
            Reporter:
            Joe Shalabi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: