日期:2014-05-16  浏览次数:20479 次

MongoDB 哪些地方会产生锁?

Which operations lock the database?

原文:http://docs.mongodb.org/manual/faq/concurrency/#what-type-of-locking-does-mongodb-use

?

The following table lists common database operations and the types of locks they use.

?

Operation Lock Type
Issue a query Read lock
Get more data from a cursor Read lock
Insert data Write lock
Remove data Write lock
Update data Write lock
Map-reduce Read lock and write lock, unless operations are specified as non-atomic. Portions of map-reduce jobs can run concurrently.
Create an index Building an index in the foreground, which is the default, locks the database for extended periods of time.
db.eval() Write lock. db.eval() blocks all other JavaScript processes.
eval Write lock. If used with the nolock lock option, the eval option does not take a write lock and cannot write data to the database.
aggregate() Read lock