ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • QE 2026-10-26
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Adds QueryPlannerAnalysis::canProvePathIsNotMissing(node, path), which returns true only when path in the output of node can never be missing (SBE Nothing).

      Index keys store a missing value as null, so a field that comes unchanged from a covered IXSCAN is never missing. A streaming $group with a multi-field object _id needs a fillEmptyNull cluster key for every field that may be missing, because index order and sort order interleave null and missing rows. This helper lets the planner skip that cluster key for fields it can prove are present.

      • STAGE_IXSCAN: true when getFieldAvailability(path) is kFullyProvided. That excludes the hashed field of a hashed index (kHashedValueProvided), every field of a non-btree index type (2d, 2dsphere, text), multikey and collated fields, wildcard object-subpath scans, and fields not in the index.
      • STAGE_PROJECTION_*: true when the projection retains path exactly and the child proves it, so computed and renamed fields return false.
      • Every other node returns false. This keeps the check correct even if the streaming group is later allowed on top of other pushed-down stages: an unhandled node can only cause unnecessary clustering, never wrong results.

      Projection::isFieldRetainedExactly (which the projection case relies on) now uses tasserts (13901900, 13901901) instead of MONGO_UNREACHABLE and invariant, and its findCommonPoint doc example is corrected. New projection_test.cpp cases cover a dotted inclusion with a deeper path and a nested sibling field.

      The helper is not called yet. A follow-up will use it in extendWithAggPipeline to record which _id fields need a cluster key on StreamingGroupNode.

      Testing: new CanProvePathIsNotMissingTest suite in planner_analysis_test.cpp, with one case per check in IndexScanNode::getFieldAvailability (ascending, descending, dotted, hashed, multikey, collated, 2d, 2dsphere, text, and wildcard index scans), unhandled nodes (collection scan, fetch, OR), and planned covered, fetched, computed-projection, and sort-above-projection plans (with plan-shape assertions).

            Assignee:
            Evan Bergeron
            Reporter:
            Evan Bergeron
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: