$match on shard key + $group on non-shard key should be distinct scan eligible

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

      On a sharded collection,

      coll.createIndex({shardKey: 1, notShardKey: 1})
      coll.explain().aggregate([
        {$match: {shardKey: {$gte: "foo"}}}, 
        {$group: {_id: "$notShardKey"}}
      ])
      

      seems to result in an IXSCAN, even though a DISTINCT_SCAN on could be used. The equivalent distinct() command results in a DISTINCT_SCAN.

              Assignee:
              Unassigned
              Reporter:
              Henri Nikku
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: