Minimize index scanning when retrieving distinct values grouped by more than one field

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • QO 2021-10-04, QO 2021-10-18
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      MongoDB 4.2 introduced the ability to avoid full index scans for aggregation pipelines that include a specific type of $group stage - those that logically request distinct information which can be obtained by scanning a single document.  This was initially implemented via SERVER-9507.

      As confirmed by this comment from a related enhancement in SERVER-40090, this optimization currently only applies when the aggregation is grouping on a single field.  We should consider expanding this optimization, or a similar one, to reduce index scanning when the _id specified for the $group is on multiple fields.    

              Assignee:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Chris Harris
              Votes:
              3 Vote for this issue
              Watchers:
              18 Start watching this issue

                Created:
                Updated: