-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
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.
- depends on
-
SERVER-21992 Inconsistent results when grouping by possibly missing values
-
- Backlog
-
-
SERVER-14832 Distinct command result set may include or exclude null/undefined depending on presence of index
-
- Needs Scheduling
-
-
SERVER-60977 Make $group _id behavior with null and missing more consistent
-
- Closed
-
- is duplicated by
-
SERVER-56294 Extend group to distinct optimization to compound keys
-
- Closed
-
- related to
-
SERVER-40090 DISTINCT_SCAN in agg is only used when certain format of _id is specified
-
- Closed
-