Avoid copying batch in received CursorResponse

XMLWordPrintableJSON

    • Query Execution
    • Fully Compatible
    • QE 2025-05-12
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None

      The storePossibleCursor function currently copies the batch of received documents into the CursorReponse it creates.
      The batch type is std::vector<BSONObj>>, so worst case we currently have one memory allocation (of known size) for the vector, as many copy operations as there are BSONObj in the batch. Copying a BSONObj will increase its ref-count, so it's not allocating any more, but it's still work that can be fully avoided.
      We can make this more efficient by moving the batch instead (using response.releaseBatch() instead of response.getBatch(). This requires the function parameter incomingCursorResponse to become non-const, and it also requires a modification to the IDL so that a non-const getter is generated.

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

              Created:
              Updated:
              Resolved: