-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
SERVER-37715 added this optimization, but left out support for queries against sharded collections. Note that while shard key fields cannot be multikey, this optimization would still make sense when the shard key is the prefix of a compound index, and we are unwinding+grouping on some field that comes after it.
E.g.
// ...shard collection on 'a' // 'b' is multikey, 'a' is not. assert.commandWorked( coll.insertMany([{a: 1, b: [1, 2]}, {a: 2, b: [3]}, {a: 3, b: 4}, {a: 4}]), ); assert.commandWorked(coll.createIndex({a: 1, b: 1})); coll.aggregate([ {$unwind: {path: "$b", preserveNullAndEmptyArrays: true}}, {$group: {_id: "$b"}} ]);
Should be able the use a DISTINCT_SCAN plan.
- related to
-
SERVER-37715 Use DISTINCT_SCAN for $unwind-$group pipelines
-
- Open
-