-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
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"