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

Ensure we never construct invalid distinct scans by hand

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 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 }

            Assignee:
            Unassigned Unassigned
            Reporter:
            henri.nikku@mongodb.com Henri Nikku
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: