-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Trivial - P5
-
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.
- fullDocumentBeforeChange up to 3 times.
- rawOplogUpdateSpec up to 2 times
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.