-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
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 }