Simplify hot path code in executors

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: Query Execution
    • None
    • Query Execution
    • Fully Compatible
    • QE 2025-08-04, QE 2025-08-18
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The PlanExecutor interface currently has the following pure virtual methods for retrieving the next single result:

          virtual ExecState getNext(BSONObj* out, RecordId* dlOut) = 0;
          virtual ExecState getNextDocument(Document* objOut, RecordId* dlOut) = 0;
      

      It turns out that getNextDocument() is never called with a non-nullptr RecordId* in any of PlanExecutor 's sub-classes, so we should remove the dlOut parameter from the getNextDocument() signature entirely.

      It also turns out that in many cases the getNext() function internally calls getNextDocument(), with the objOut* pointer being a non-nullptr. We can optimize these cases too.
      Streamlining this code will lead to less conditional branches and less temporary object creations on the executor hot path code.

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

              Created:
              Updated:
              Resolved: