Avoid repeated field lookups in change stream post-image stage

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Trivial - P5
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: Change streams
    • None
    • Query Execution
    • Fully Compatible
    • QE 2025-10-27
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The ChangeStreamAddPostImageStage looks up fields in the input document redundantly, e.g.

      The Document class adds a field value to a cache once the field has been looked up once, so repeated lookups should normally be fast. However, the Document class uses a linear scan over the cached fields if the number of looked up fields is <= 4, so there can still be some penalty. It is best to avoid repeated lookups of the same field altogether.

      Additionally, the class converts string field values to std::string s unnecessarily in a few cases (e.g. here and here). This should be converted to use StringData instead.

            Assignee:
            Jan Steemann
            Reporter:
            Jan Steemann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: