Is it possible to store only one revision of each document in Couchbase so that it doesn’t inflate after each update using set
? This question is interesting in context of Couchbase Lite too.
Hi @issacthomas the Couchbase Server (note, I don’t work with mobile or CB Lite) is underpinned by the Data Service which is a high performance KV store. I want to highlight a few points:
- When you to an insert (or upsert) you only have one document stored (ignoring replicas).
- If you delete a document it will be deleted but DCP will remember the metadata as deleted.
- If a document expires it gets marked as a tombstone and will be cleaned up on the configurable metadata purge interval.
- Couchbase can scale either vertically or horizontally to support over 1M ops/sec. and it can do this just by adding nodes without repartitioning.
Now with the above said Couchbase works on buckets and the buckets clean themselves up in a lazy fashion (compaction, tombstone cleaning, etc.). I know it’s sort of odd seeing “space” seming being sucked up in a bucket when you just update the same 10M documents over and over.
However rest assured that you only keep one copy of a document (ignoring replicas) and eventually the old space is reclaimed. Hey when I first started at couchbase this seemed weird (even watching bucket space change when my system was quiescent WRT end-user activity). The design is such that we can answer queries or KV requests fast rather than waste time on housekeeping on every set or delete. You might think of the operation similar to a log based or a COW file system. The big takeaway here is just because you see say 127MB used in a 200MB bucket and you only have a few small docs (say 100K) have you ever run out of space have you ever dropped below a 100% residency ratio or is there some other performance impact. If the answer is no don’t sweat things.
I am sure that others more knowledgeable can explain things further, just ping me back if you need further details or a more technical explanation and I will hook you up.