Thread ExpCtx directly through to explain or PlanExecutorSBE

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, in explain.cpp we access the ExpCtx through the CanonicalQuery that is stored on the executor (e.g. PlanExecutorSBE) (example#1, example#2).

      The code here makes the assumption that every executor will have a single CQ driving it and thus, it accesses the ExpCtx through the CanonicalQuery. However, with join ordering (JOO), we now have executors that have multiple CanonicalQuerys (one per collection in the join graph) and thus, we pass in a nullptr when constructing the PlanExecutorSBE. PlanExecutorSBE has no _expCtx member of its and it only reaches ExpCtx through its _cq field, so when the _cq is null there is no ExpCtx accessible via PlanExecutorSBE and thus not available in explain.cpp.

      We should decouple ExpressionContext from CanonicalQuery by threading expCtx directly through to the explain infrastructure (e.g. via PlannerContext) or stashing a pointer to the ExpCtx on PlanExecutorSBE. This enables the idiomatic approach of consulting the snapshotted ExpCtx for query knobs and query settings, rather than reading global knob values directly which may change mid-query (see the TODO comment in SERVER-123546).

            Assignee:
            Unassigned
            Reporter:
            Naafiyan Ahmed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: