Make DocumentSource::usedDisk() const

XMLWordPrintableJSON

    • Query Execution
    • QE 2025-07-07
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      DocumentSource::usedDisk() is (subjectively) expected to be const, however it is not.

      Most stages cannot spill to disk, so the result is always false.

      Some stages can spill and the method returns _stats.planSummaryStats.usedDisk, where _stats is some stage specific statistics object, which can also be retrieved with DocumentSource::getSpecificStats() method.

      Some stages with sub-pipelines don't update their statistics during the execution, within the usedDisk() non-const method, which makes the API contextual and prone to errors.

      Updating _stats.planSummaryStats.usedDisk should probably be done when the pipeline is officially 'closed' and there will be no more 'getNext()' calls. This will allow making DocumentSource::usedDisk() method const, or remove it completely, as suggested in SERVER-53759.

      This minor improvement is related to SPM-4106, but it is out of scope of the project.

              Assignee:
              Niels Lohmann
              Reporter:
              Romans Kasperovics
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: