Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-68677

Skip row store projection in column index plans when possible

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • 69

      In the row store fallback path of column index plans, we apply a projection to the row store document to ensure that it has the same "schema" as the documents that would have been returned by the column index path. This is fairly expensive, and can often be skipped (including any time there is a $group above the column scan).

      This would build off of the analysis done in SERVER-66061 where we detect cases where a projection is not necessary. In the same cases (unless I'm forgetting an edge case), we should be able to skip adding this expression which projects the full document retrieved from the row store. That is added [here](https://github.com/10gen/mongo/blob/21b7dfd8f85224445da4f6098f22ac463ee18f72/src/mongo/db/query/sbe_stage_builder.cpp#L764) unconditionally. We should be able to attach some boolean to the ColumnIndexScanNode which can say whether or not a projection is necessary. That same ColumnIndexScanNode should be available and in scope in [this analysis from SERVER-66061](https://github.com/10gen/mongo/blob/21b7dfd8f85224445da4f6098f22ac463ee18f72/src/mongo/db/query/planner_analysis.cpp#L424). There we could add a boolean flag to say "I don't need an exact schema", in case there is a subsequent $group stage. ian.boros@mongodb.com suggested calling this "isStrict" or something like that.

      We should be able to test this code path by inspecting the SBE plan in the explain output, where we should be able to tell if there is a row store expression or not.

            Assignee:
            steve.tarzia@mongodb.com Steve Tarzia
            Reporter:
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: