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

$sort can be eliminated after order preserving $group

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

      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:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            rushan.chen@mongodb.com Rushan Chen
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: