We are facing a very annoying issue with Mongoose.
The save method takes around 500 / 600ms and it is very CPU consuming.
We have a sub-document with 50000 array elements which gets a new element (history) every each update using push.
Here is the code:
..... very large function
variable.value = parseFloat(value);
variable.history.push([{
value: parseFloat(value),
timestamp: dateNow
}]);
await variable.save();
..... end function
I have indexes on history and _id.
Any hint on why this is taking so long and consuming 60%...80% CPU ?
Thanks