Content Deep Dive
Concurrency Behavior: MongoDB vs. Couchbase
Blog post from Couchbase
Post Details
Company
Date Published
Author
Keshav Murthy
Word Count
2,845
Language
English
Hacker News Points
-
Summary
MongoDB queries can fail to include all the matching documents due to concurrent updates that move data from one portion of the index to another, resulting in either overcounting or undercounting. This issue affects queries that use indexes and is more pronounced when multiple documents are updated concurrently. In contrast, Couchbase returns the expected number of qualifying documents even with concurrent updates, thanks to its stable index scans, which provide protection against this issue. To mitigate this problem, developers should design data models that select and update only one document for each query, avoiding multi-document queries in MongoDB.