I have many data for each user that with write heavy and many for each separate users that there is not any relation between user's data; so there is two options for me to store them: 1. keep all user's data in one collection that is much easier, and 2. keep every user's data in a separate collection; Now i need to know is a locking battle-neck for parallel writes in first option or not, while my updates/inserts are many but on one by one (there is no need to update/insert many (multi: true). does mongo lock the whole collection for an updateOne/insertOne (multe: false) or only does it for updateMany/insertMany (multi: true) cases?

1 Answer 1


According the documentation MongoDB locks the database only when create an index in the foreground ( this option does not exists any more in MongoDB 4.2. ).

On the other hand the collection are never exclusively locks.

See more what locks are taken on MongoDB on What locks are taken by some common client operations?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.