Skip redundant shard filter when eligibility checks shard-key ownership

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc1
    • Affects Version/s: None
    • Component/s: Change streams
    • None
    • Query Execution
    • Fully Compatible
    • QE 2026-07-20
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Single-document lookups apply a post-read shard filter to drop orphans. When the LocalLookupEligibility already resolves locality from the documentKey's shard key (ShardedClusterLocalLookupEligibility, used by change-stream updateLookup), that ownership check makes the post-read filter redundant. Add LocalLookupEligibility::checksShardKeyOwnership() and skip the filter in both the Express and SBE executors when it is set.

      $search idLookup (AlwaysLocalEligibility) does not inspect a shard key, so it still applies the filter; SBE gains shard filtering via INCLUDE_SHARD_FILTER for that path.

      Safe for change streams because the SBE change-streams updateLookup path already relies on per-shard _id uniqueness (no same-_id orphan), so a Local decision uniquely identifies the owned document.

            Assignee:
            Denis Grebennicov
            Reporter:
            Denis Grebennicov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: