I have a question about saving part of a document and saving the entire document.
I have a document with an array. If I update an item in this array the oplog will only have part of the changed array or it will have the entire document with the complete array.
If the oplog has the whole document even in one update action would it be better to use “db.collection.save()”? Because in both cases the oplog would have the entire document to be updated
It depends on the operation. As it currently stands with MongoDB 5.0.3, some array operation such as $push
do not rewrite the whole array, but $addToSet
will.
There is no guarantee that this will always be like this in the future though, as the oplog is used internally and thus being improved constantly.
Best regards
Kevin
1 Like