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

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

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

      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:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            christopher.harris@mongodb.com Chris Harris
            Votes:
            1 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: