-
Notifications
You must be signed in to change notification settings - Fork 97
MongoDB Indexes
prohaska edited this page Apr 15, 2013
·
1 revision
http://docs.mongodb.org/manual/core/indexes/
The following discussion refers to the design inside of MongoDB 2.4
- ensure index holds a write lock on the database until the index is built
- ensure index blocks queries
- s.a.ensureIndex() blocks s.a.find()
- s.a.ensureIndex() blocks s.b.find()
- ensure index blocks insertions
- s.a.ensureIndex() blocks s.a.insert()
- s.a.ensureIndex() blocks s.b.insert()
- ensure index blocks another ensure index on the same collection
- s.a.ensureIndex({a:1}) blocks s.a.ensureIndex({b:1})
- ensure index blocks another ensure index on a different collection in the same database
- s.a.ensureIndex() blocks s.b.ensureIndex()
- ensure index on different databases run in parallel
- s.a.ensureIndex() runs in parallel with t.a.ensureIndex()
- background ensure index does not finish until the index is built
- background ensure index periodically yields the processor by sleeping for awhile
- background ensure index + queries run in parallel
- background ensure index + inserts run in parallel
- multiple background ensure index operations on the same collection run in parallel
- The background indexer is run on the client thread.
- A write lock on the database is held while indexing.
- Periodically, the background indexer yields the processor. It releases the database lock before sleeping for awhile and then reacquires it.
- Concurrency of other operations on the database occur when the indexer is sleeping.
- This algorithm is SLOW.