From what I have observed:
- For every document you create, a revision-manager document is also created. This revision-manager keeps track of the latest revision and also maintains a history of all revisions in an array.
- Every time you update a document, a new document is created (whyyyyy???). The revision-manager document's latest pointer points to this new document and adds the previous document to its revision history list.
- So, in every update operation Sync-Gateway is adding a new document and also modifying revision-manager document.
This is very inefficient way of doing version control where a copy of the whole document is maintained for version control instead of just the diff as this is going to take a lot of space. (For example : It is taking 8.03MB of disk space for doing 500 taps on a single todo item in the "GrocerySync-Android" sample app. Also, the revision manager document has become greater than 2.5 kb and I am getting a message saying you cannot modify a document more than 2.5 kb in size. Why????)
Questions:
- What is the _sync:local: document about?
- Is it possible to turn off this default behaviour of creating a new document on update and keeping just the latest copy. (One way could be to delete older revs in the client but I guess this would not modify the revision-manager document.)
In a distributed system, especially used for iOS/Android and other embedded devices it's important to keep the full set of properties in each revision.
Using the patch/diff approach in such system could lead to more inconsistencies, for example an update would only make sense if there were some previous state too. Otherwise, showing the diffs of a document to the user wouldn't provide a great user experience. It's very well suited for other use cases however, versioning of source code for example (Git, Mercurial...)
It could be possible to leverage the patch/diff approach in the replication protocol. There is an open ticket in the Couchbase Lite iOS repository discussing the possibilities of only transferring deltas of revisions.
If you only want to keep a small number revisions, change the
maxRevTreeDepth
property to specify the number of revisions to keep in the tree history of a document (the default is 20, read more here).