$sort can be eliminated after order preserving $group

XMLWordPrintableJSON

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

      In classic, we have implemented streaming group (SERVER-70267), which is group id order preserving due to the conditions when a query is eligible for streaming group.

      This order preserving property can benefit further stages after a streaming group, eg a sort on the same order.

      Post group sort is often used with $limit/$skip to support pagination of results, for example as modelled by this workload:

      https://github.com/10gen/PrivateWorkloads/blob/production/src/workloads/customer_representative/coinbase/timeseries/GroupDateTruncLimit.yml

      Eliminating the sort would greatly improve query performance.

      When SBE supports streaming group, the same post group sort eliminatino also applies.

            Assignee:
            [DO NOT USE] Backlog - Query Optimization
            Reporter:
            Rushan Chen
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: