Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-8125

Investigate changes in SPM-3182: Support shard filtering in distinct scan optimization

    • Type: Icon: Investigation Investigation
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: None
    • Component/s: None
    • None
    • Developer Tools
    • Not Needed

      Original Downstream Change Summary

      While no direct user impact, there may be some cases where customers no longer see a distinct scan and thus performance may differ (but the results will be correct!). There will also two fields added to the distinct scan stage in explain output (no existing fields changed/removed)- see the design for details.

      Description of Linked Ticket

      Epic Summary

      Motivation

      Fix a query correctness bug.  As described in SERVER-42160 (and its comments), plans using DISTINCT_SCAN on sharded collections may incorrectly return orphaned documents because no SHARDING_FILTER is included.

      Summary

      Incorporate shard filtering into the DISTINCT_SCAN.  The most difficult case is when the shard key is not part of the index being scanned; each step of the DISTINCT_SCAN must also fetch the full document and apply the shard filter to decide whether the current value is valid or is an orphan that should be skipped.  Note that there is a risk here that the DISTINCT_SCAN will become slower than a regular IXSCAN in cases where there are few duplicates, so we should test that the multiplanner is trialing both options.

      DISTINCT_SCAN is currently only implemented in the classic query planner and execution engine, so we'd either implement this in classic or expand the scope to implement DISTINCT_SCAN in SBE + stagebuilders.

      Documentation

      Product Description
      Scope
      Technical Design
      Docs Update

            Assignee:
            Unassigned Unassigned
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: