Use wildcard indexes in SBE $lookup

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Query Planning
    • None
    • Query Execution
    • QE 2026-07-06, QE 2026-07-20
    • None
    • None
    • None
    • None
    • None
    • None
    • None

        1. Summary

      Allows SBE to use a covering wildcard index on the foreign side of a $lookup instead of forcing the entire join to the classic engine, using the existing Dynamic Indexed Loop Join (DILJ) strategy. Wildcard indexes are sparse-like (they omit documents missing the indexed path), so per local document at runtime, scalar keys seek the wildcard index while null/missing/array/object keys fall back to a collection scan. Only single-path, non-partial wildcard indexes are eligible for pushdown; compound and partial wildcard indexes still force the classic engine.

      • Added wildcard-index eligibility to the SBE pushdown gate in `planner_analysis.cpp`, and narrowed the "force classic" path to only compound/partial wildcard indexes; wildcard indexes are also treated as sparse for INLJ/DILJ index selection ordering.
      • When a wildcard index is chosen, expands the placeholder `IndexEntry` (e.g. ` {"$**": 1}

        `) into a concrete `

        {foreignField: 1}

        ` entry via `wildcard_planning::expandWildcardIndexEntry` so downstream code treats it like any other index.

      • In `query_planner.cpp`, rewrites the SBE index scan's key pattern and `multikeyPaths` to insert the wildcard index's virtual `$_path` component ahead of the foreign field, and binds it via a constant IET interval, so seeks match the real on-disk key shape.
      • Extended the DILJ runtime branch in `gen_lookup.cpp` with an array/object type guard alongside the existing collation and sparse guards, since a wildcard index stores one key per sub-field and can't answer array/object local keys with a point seek.

            Assignee:
            Prabhas Penumatsa
            Reporter:
            Prabhas Penumatsa
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: