couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <>
Subject Re: Changes API - purged?
Date Fri, 23 Aug 2013 16:38:29 GMT
Nope. I don't think you should take "each document has a seq no" too
seriously, the number changes and has no particular meaning beyond
providing a means of synchronizing databases and indexes.


On 23 August 2013 17:08, James Hayton <> wrote:
> So something interesting here to me is that each document had a seq no... Is there any
way to figure out what that is from the id/rev?
> On Aug 23, 2013, at 8:15 AM, Jens Alfke <> wrote:
>> On Aug 23, 2013, at 1:01 AM, Jens Rantil <> wrote:
>>> Just to be clear, does compaction influence the changes feed in any way?
>> It may help to think of the changes feed this way:
>> Every database has a last-sequence counter (similar to a SQL table’s autoincrement
>> Every document has a sequence number*.
>> Whenever a document is updated (i.e. a revision is added) its sequence number is
changed to the next available sequence count.
>> The changes feed is just a listing of documents ordered by their current sequence
>> (Under the hood, the database has a separate b-tree index that maps sequence numbers
to document IDs.)
>> Thus the effect is that updating a document moves it to the end of the changes feed,
with a new sequence number.
>> Compaction doesn’t have any effect on this at all; all it does is prune intra-document
revision data.
>> —Other Jens ;)
>> * This gets more complex with BigCouch/Cloudant, because it’s clustered. The opaque
sequence IDs it shows clients are actually aggregates of the sequence numbers of all the nodes
in the cluster.

View raw message