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

Extend group to distinct optimization to compound keys

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Performance
    • Labels:
      None
    • Query Optimization

      > db.coll1.insert({a:1, b:2})
      ...
      > db.coll1.createIndex({a:1, b:1})
      ...
      > db.coll1.explain().aggregate({$group: {_id: ["$a", "$b"]}})
      ... "inputStage" : { "stage" : "COLLSCAN" ...
      

      The aggregation on a single key generates efficient DISTINCT_SCAN:

      > db.coll1.explain().aggregate({$group: {_id: "$a"}})
      ... "inputStage" : { "stage" : "DISTINCT_SCAN", ...
      

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            ruslan.abdulkhalikov@mongodb.com Ruslan Abdulkhalikov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: