-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
QO 2024-11-25
In `constructCoveredDistinctScan`, we construct a DISTINCT_SCAN plan by hand and then call `analyzeDataAccess` to finalize it. This seems risky, since we might end up constructing a distinct scan even when some properties of the index make it unsuitable for a DISTINCT_SCAN (we perform more checks in `turnIxScanIntoDistinctScan` than in `getDistinctNodeIndex`). A safer approach would be to construct an INDEX_SCAN on the desired index, let `analyzeDataAccess` convert it to a DISTINCT_SCAN, and return nullptr if plan couldn't be converted. If this approach leads to test failures, we should then update `getDistinctNodeIndex` accordingly.
Example query where this happens:
distinct("a", undefined) over [ { "a" : [ ] } ] with index { "a" : 1 }
- is related to
-
SERVER-97239 getUniqueResults() in pretty_md should unwind arrays
- Closed
- related to
-
SERVER-97238 $group with $first/$last to distinct scan optimization might incorrectly unwind arrays
- Open