Anurag Sharma
Anurag Sharma

Reputation: 5049

mongo write lock behavior

I have a question on mongo locks. Basically I have to perform some write operation on the table(insert/ delete/ update). When I read this link Locking in Mongodb. It says "Locks are “writer greedy,” and when a write lock exists, a single write operation holds the lock exclusively, and no other read or write operations may share the lock.

My question is -- The lock is memory block based or we have a single lock on entire db. What I was thinking is concurrently run 2 scripts scanning 2 memory blocks of mongodb (planning to scan 2 million documents in one query) and perform write operation side by side thereby increasing the performance and saving time.

I searched on net about this but didnt find anything satisfactory.

Any help will be deeply appreciated

Upvotes: 3

Views: 2194

Answers (1)

Sammaye
Sammaye

Reputation: 43884

The write lock has nothing to do with memory, MongoDB is not an in-memory database, the OS merely caches the working set of the mongod process to RAM. MongoDB has no memory hooks in its program.

The write lock is also on database level as such your plan is not feasible.

Upvotes: 5

Related Questions