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

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

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

      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 Unassigned
            Reporter:
            henri.nikku@mongodb.com Henri Nikku
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: