Reduce overhead of extracting timestamp from oplog entry

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Change streams
    • None
    • Query Execution
    • QE 2026-08-31, QE 2026-09-15
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Change streams track the timestamp of every seen oplog entry inside the `CollectionScan::setLatestOplogEntryTimestamp(const Record& record)` function.
      This function previously BSONified the oplog entry only to extract the 'ts' field again.
      For oplog records, the timestamp is directly encoded in the record id, so this conversion can be saved.

      This change adds a fast path inside `setLatestOplogEntryTimestamp()` for extracting the numeric timestamp value from the record id, skipping the unnecessary BSONificiation.
      This makes the `setLatestOplogEntryTimestamp()` function run ~55% faster in optimized builds. This is beneficial because the function is called for every oplog entry encountered by a change stream, not just the oplog entries that make it through the change stream's oplog match filter.

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

              Created:
              Updated: