How to limit the number of document updates?
Hi
I want to limit the number of document updates in one command.
for example
db.users.updateMany(
<filter>,
<update>,
{
limit : 100
}
);
https://www.mongodb.com/community/forums/t/how-to-limit-the-number-of-document-updates/102204/3
-
Tyler commented
Want to call out that while there are presumably correctness issues to this when it comes to sharding, most uses of this sort of pattern I assume are to ultimately update all documents in a large collection without overwhelming the cluster.
If you have 1 billion documents (frankly lower numbers this still holds) and I want to update each one to add a field (or remove a field).
Right now there is not an easy way to slowly migrate these without doing something that feels way less performant than what MongoDB could do internally.