|
For every operation/command report resources used, like other stats from the operation.
In addition to reporting it back inline also provide a record and the ability to collect it out-of-band from the operation itself (like in the profile collection).
A good example of this would be to account for storage during write operations:
db.b.update({}, {$set:{a:1}})
|
Update WriteResult({
|
"ok" : 1,
|
"nModified" : 12,
|
"n" : 12,
|
"resourcesUsed" : {cpu: 1000, storage:{collection:136, indexes:42}, memory:56000}, // cpu units = cycles?, storage/mem bytes
|
"lastOp" : Timestamp(1389888187, 1),
|
"writeErrors" : [
|
]
|
})
|
// Remove frees space and results in negative storage
|
db.b.remove({a:1})
|
Remove WriteResult({
|
"ok" : 1,
|
"n" : 12,
|
"resourcesUsed" : {cpu: 988, storage:{collection:-234234, indexes:-42234}, memory:16000000},
|
"lastOp" : Timestamp(1389888187, 1),
|
"writeErrors" : [
|
]
|
})
|
|