From dev-return-20493-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Tue Feb 7 16:03:35 2012 Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DF4439D95 for ; Tue, 7 Feb 2012 16:03:34 +0000 (UTC) Received: (qmail 94249 invoked by uid 500); 7 Feb 2012 16:03:34 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 94162 invoked by uid 500); 7 Feb 2012 16:03:33 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 94154 invoked by uid 99); 7 Feb 2012 16:03:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 16:03:33 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of north.n@gmail.com designates 209.85.160.180 as permitted sender) Received: from [209.85.160.180] (HELO mail-gy0-f180.google.com) (209.85.160.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 16:03:27 +0000 Received: by ghbz22 with SMTP id z22so3876230ghb.11 for ; Tue, 07 Feb 2012 08:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=G72oO2r/UCbqktrc0u+T5TEq6PLS5p18aK1JNWIEcIQ=; b=Mp3x3PdWvZc3ZPisVbz3LbfQuG78UHBtUaQd2hHFM7+AAEDdoBTtyNOXw9eQb8iYB0 5x3hjsK+fvM2RH3ebogaFWB1VJrlbDF1a5dPY6nFwLlbVaY6WTjBCEfSZ+Uvfvvx9sOQ l3rbQou/XsScfqpPLh63CoksWB3l2445bBOsA= MIME-Version: 1.0 Received: by 10.236.80.4 with SMTP id j4mr32989606yhe.120.1328630586171; Tue, 07 Feb 2012 08:03:06 -0800 (PST) Received: by 10.236.190.137 with HTTP; Tue, 7 Feb 2012 08:03:06 -0800 (PST) Date: Tue, 7 Feb 2012 16:03:06 +0000 Message-ID: Subject: Order of document ids vs order of _changes ids From: Nick North To: dev@couchdb.apache.org Content-Type: multipart/alternative; boundary=20cf3005101020606504b861ea6a --20cf3005101020606504b861ea6a Content-Type: text/plain; charset=ISO-8859-1 I have a question about the order in which documents are committed to the database, which I hope a knowledgeable dev can help me out with. The question is (I think): if I create documents, using CouchDb-assigned document ids, will they appear in the _changes feed in the order that the ids were assigned? For example, if the id generation algorithm successively supplies ids aa, bb, cc, will the changes feed contain aa, bb, cc in that order, or could a document with a later id "overtake" an earlier one in the process of being committed to the database to yield, say, aa, cc, bb? A secondary question is: if the order is preserved, can that be relied on in future CouchDb versions, or is it coincidental and may change one day? A bit of background might help, and may possibly suggest that I'm not asking the right question. I have a set of mutually replicating databases which have a CouchDb id generation algorithm that produces monotonic increasing globally unique document ids (details here). I'd like to be certain that, if document id xx has been replicated from one database to another, then all documents that are replicated later have higher ids than xx. It struck me that this might not be the case if multiple simultaneous document creations are processed concurrently and get their document ids assigned early in the process - then a small document with a later id might be processed more quickly than a large one with an earlier id and get into the database first. Any insights would be very much appreciated. Many thanks, Nick --20cf3005101020606504b861ea6a--