Add reason to the rankerChoice object in explain V3

XMLWordPrintableJSON

    • Type: Sub-task
    • Resolution: Fixed
    • Priority: Critical - P2
    • 9.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Goal

      Populate the reason field of queryPlanner.rankerChoice in explain V3. SERVER-132229 (PR #59603) emits the envelope with reason: "" as a placeholder; this ticket replaces the placeholder with the real value and discharges the corresponding TODO marker.

      Mechanism

      Each plan-ranking strategy records its terminal state at the point where the decision is made, and that value is threaded to the single emission point in explain (next to the existing chosenRanker source, OpDebug::planRankerMethod). The reason must never be inferred after the fact from which statistics happen to be present in the ranking result — several (chosenRanker, reason) pairs are indistinguishable by surviving statistics alone.

      Reason values and where they are decided

      Per the valid-combination table in the design doc ("Extend Explain for customer troubleshooting", section "Information computed during query planning by each plan ranker"):

      • Config-fixed choices in the ranking dispatch (plan_ranking/plan_ranker.cpp): featureFlag, queryKnob, singlePlan
      • Mixed / NoMultiplanningResults (cbr_for_no_mp_results.cpp): noMultiplanningResults, mpEarlyExitOrResult, smallCollection, inestimableNode (CBR fallback)
      • Mixed / EstimateRankingEffort: cbrCheaperThanMp, mpCheaperThanCbr, mpEarlyExitEofOrFullBatch, inestimableMP, inestimableNode
      • CBR strict-mode fallbacks: inestimableNode, histogramCEInternalColl

      Scope notes

      • Include representative per-configuration tests: a handful of (knob configuration, collection shape) -> expected reason rows covering each strategy family. The exhaustive validity matrix over (requestedRanker, chosenRanker, reason) triples is deliberately left to SERVER-132230, which depends on this ticket — rationale: that matrix asserts the combined object and cannot pass before all three fields are real.
      • The optional phases decision trail (the design doc's may-defer enrichment) is out of scope here; the defer-or-drop decision is recorded at SERVER-132230.

            Assignee:
            Timour Katchaounov
            Reporter:
            Timour Katchaounov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: