What data is actually stored in a B-tree database in CouchDB?

Posted by Andrey Vlasovskikh on Stack Overflow See other posts from Stack Overflow or by Andrey Vlasovskikh
Published on 2010-04-19T15:49:07Z Indexed on 2010/04/19 21:33 UTC
Read the original article Hit count: 220

I'm wondering what is actually stored in a CouchDB database B-tree? The CouchDB: The Definitive Guide tells that a database B-tree is used for append-only operations and that a database is stored in a single B-tree (besides per-view B-trees).

So I guess the data items that are appended to the database file are revisions of documents, not the whole documents:

            +---------|### ...  
            |           |
   +------|###|------+     ... ---+
   |        |        |            |
+------+ +------+ +------+     +------+
| doc1 | | doc2 | | doc1 | ... | doc1 |
| rev1 | | rev1 | | rev2 |     | rev7 |
+------+ +------+ +------+     +------+

Is it true?

If it is true, then how the current revision of a document is determined based on such a B-tree?

Doesn't it mean, that CouchDB needs a separate "view" database for indexing current revisions of documents to preserve O(log n) access? Wouldn't it lead to race conditions while building such an index? (as far as I know, CouchDB uses no write locks).

© Stack Overflow or respective owner

Related posts about couchdb

Related posts about b-tree