Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-69056

'explain' should include actual resource consumption costs when run with verbosity 'executionStats'

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • QE 2022-11-14, QE 2022-11-28

      Original title: 'explain' should include estimated resource consumption costs
      In order to make it easier for MongoDB users to tally resource consumption costs for Serverless, it would be useful for resource consumption to be returned as part of the 'explain' output.

      Example:

      test> db.foo.find({}).explain()
      {
        explainVersion: '1',
        queryPlanner: {
          namespace: 'test.foo',
          indexFilterSet: false,
          parsedQuery: {},
          queryHash: '17830885',
          planCacheKey: '17830885',
          maxIndexedOrSolutionsReached: false,
          maxIndexedAndSolutionsReached: false,
          maxScansToExplodeReached: false,
          winningPlan: { stage: 'COLLSCAN', direction: 'forward' },
          rejectedPlans: []
        },
        command: { find: 'foo', filter: {}, '$db': 'test' },
        operationMetrics: { docBytesRead: 51, docUnitsRead:2 }
      

      Actual implementation:

      When explain is run with verbosity executionStats or higher, the "executionStats" now contain "operationMetrics" as well if profileOperationResourceConsumptionMetrics is enabled. These operationMetrics show runtime stats, if they are not zero. The stats are nested within "operationMetrics" which is nested in "executionStats." They include:

      "cpuNanos"
      "cursorSeeks"
      "docBytesRead"
      "docBytesWritten"
      "docUnitsRead"
      "docUnitsReturned"
      "docUnitsWritten"
      "idxEntryBytesRead"
      "idxEntryBytesWritten"
      "idxEntryUnitsRead"
      "idxEntryUnitsWritten"
      "totalUnitsWritten"
      "keysSorted"
      "sorterSpills"

            Assignee:
            adi.agrawal@mongodb.com Adi Agrawal
            Reporter:
            milkie@mongodb.com Eric Milkie
            Votes:
            0 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: