Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 59B91D02D for ; Fri, 9 Nov 2012 08:23:07 +0000 (UTC) Received: (qmail 3924 invoked by uid 500); 9 Nov 2012 08:23:05 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 3792 invoked by uid 500); 9 Nov 2012 08:23:05 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 3738 invoked by uid 99); 9 Nov 2012 08:23:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2012 08:23:03 +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 (nike.apache.org: domain of north.n@gmail.com designates 209.85.210.180 as permitted sender) Received: from [209.85.210.180] (HELO mail-ia0-f180.google.com) (209.85.210.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2012 08:22:57 +0000 Received: by mail-ia0-f180.google.com with SMTP id f6so2500314iag.11 for ; Fri, 09 Nov 2012 00:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hniyoVNgSP+vKEhRFaJKVqLq7XmQUl/xaTP44D/fn5A=; b=VIk6lffGT0btvlhmDjNExh0ZugQgTTuOyFuBuW+ukQ1C+KDdP5kC88wmjCjueQhhqq M6C99BAsX5lvBx2TG5xFjnSteLdjvBiKlCes5ssyXPFAlUf+DKbFRsDFGCoo2jB/6kLE X6gOFIdmiStkPQDBDlb9yBdpFUQ5Gs7LvTeWajkNyQ7fT8u3Oy+k5aVWFK+dTj9uHFQg Mupaf4TFAIKYjw2y9u/YSJwUcAGQcstd9yLSCjC8cQpFDVjhwEgkXi34pkACjiRrl5T8 ft5oDuC36B3Nlreb5UpxMZpTBevq5xmvkZDHLkdLBNSMRioAPGf9JnR9U9vQma9NU4Tq eixw== MIME-Version: 1.0 Received: by 10.50.195.168 with SMTP id if8mr673877igc.71.1352449356141; Fri, 09 Nov 2012 00:22:36 -0800 (PST) Received: by 10.64.70.5 with HTTP; Fri, 9 Nov 2012 00:22:36 -0800 (PST) In-Reply-To: References: <20121108123234.5b64c597@eee-az> <20121108211246.275eecaf@svilendobrev.com> Date: Fri, 9 Nov 2012 08:22:36 +0000 Message-ID: Subject: Re: are auto-generated uuids unique across server-instance From: Nick North To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=14dae934102d7313b704ce0ba75e X-Virus-Checked: Checked by ClamAV on apache.org --14dae934102d7313b704ce0ba75e Content-Type: text/plain; charset=ISO-8859-1 Not sure if this addresses your problem but... The utc_id_suffix algorithm is intended for occasions when you want ids to be time-ordered on each server, and you want to be able to distinguish which server they originate from when replicating. The uuids are of the form [timestamp]+[suffix] where the suffix is set in the server's ini file. The Erlang clock guarantees to return a different and increasing value on every call, so uuids are unique on each server, even if several arrive during the same clock tick. By giving each server a different suffix you can distinguish document origin, and you can deconstruct the uuid into the timestamp and its suffix and use both in your view key if you want to deal with the case where servers have different local times (you then have to query the view for each server independently of course). You do need to watch out for replication though, as this happens in parallel so documents may replicate out of order, which makes it a little difficult to write a client that picks up every document as it arrives. utc_id_suffix is not in CouchDb 1.2 though - it's coming in 1.3. Nick North On 9 November 2012 01:31, Andrey Kuprianov wrote: > Add a postfix to uuid. Just as an idea: uuid+[timetamp in ms]+[server > identifier] > > So you will get something > like cc606fe70aa52bd60da6c94835cda3ef-1349789839150-A for a document id. > > Then if you output all ids into a view with: > > function(doc) { > emit(doc._id, null); > } > > you will get your docs chronologically ordered as you will also know which > server they came from. > > > On Fri, Nov 9, 2012 at 3:12 AM, svilen wrote: > > > i'm asking this because i do have a machine that is 4minutes ahead > > of others.. and thus a few things relying on (sorted-by) local > > clock() timestamp went plop. And everyone-with-own-idea-of-time is > > going to be the norm.. > > > > so now i'm looking for some kind of autoincrementing suffix, additional > > to server-side clock being stamped on documents.. coz incoming order > > does matter (multiple in same microsecond). Looked at _local_seq for > > that (by copy into another field to unlocal it), but not sure if it > > is always increasing (or sufficienty "always"). probably is. > > > > anyway, thanks > > svil > > > > On Thu, 8 Nov 2012 10:36:13 -0800 > > Mark Hahn wrote: > > > > > I use utc_random. It is really useful. Easy to sort by creation > > > date. And you can even extract the creation date from the _id and > > > save a field. > > > > > > On Thu, Nov 8, 2012 at 10:21 AM, Robert Newson > > > wrote: > > > > > > > Hi, > > > > > > > > Here's the pertinent information on the various UUID algorithms > > > > CouchDB supports; > > > > > > > > [uuids] > > > > ; Known algorithms: > > > > ; random - 128 bits of random awesome > > > > ; All awesome, all the time. > > > > ; sequential - monotonically increasing ids with random increments > > > > ; First 26 hex characters are random. Last 6 increment in > > > > ; random amounts until an overflow occurs. On overflow, the > > > > ; random prefix is regenerated and the process starts over. > > > > ; utc_random - Time since Jan 1, 1970 UTC with microseconds > > > > ; First 14 characters are the time in hex. Last 18 are random. > > > > ; utc_id - Time since Jan 1, 1970 UTC with microseconds, plus > > > > utc_id_suffix string > > > > ; First 14 characters are the time in hex. uuids/utc_id_suffix > > > > string value is appended to these. > > > > > > > > The default is "sequential". > > > > > > > > B. > > > > > > > > > > > > On 8 November 2012 18:13, Mark Hahn wrote: > > > > > > > > > http://en.wikipedia.org/wiki/Universally_unique_identifier > > > > > > > > > > On Thu, Nov 8, 2012 at 2:31 AM, Andrey Kuprianov < > > > > > andrey.kouprianov@gmail.com> wrote: > > > > > > > > > > > It's a uuid. It's unique wherever > > > > > > > > > > > > > > > > > > On Thu, Nov 8, 2012 at 6:32 PM, svilen > > > > > > wrote: > > > > > > > > > > > > > hi > > > > > > > are auto-generated uuids (when doc is saved without assigned > > > > > > > id) unique across server-instance, or only within the > > > > > > > database? > > > > > > > > > > > > > > i.e. can i take a doc from one database and write > > > > > > > it as-is-without-the-_rev into another database? > > > > > > > can that become a problem? > > > > > > > > > > > > > > ciao > > > > > > > svil > > > > > > > > > > > > > > www.notionery.com > > > > > > > www.svilendobrev.com > > > > > > > > > > > > > > > > > > > > > > > > > --14dae934102d7313b704ce0ba75e--