couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Davies <>
Subject Re: Does CouchDB check autogenerated document id's?
Date Fri, 02 Jan 2009 15:55:15 GMT

On 2 Jan 2009, at 15:34, A.J. Brown wrote:

> I'm writing a proof of concept for our organization to use couchdb  
> for our content.  Part of the task will be generating document Ids  
> from legacy Ids (autonumber integers).    This would be done by  
> simply doing an md5() hash on the legacy id.
> Since we're storing the same 32char hex string as our user-provided  
> document ids, When CouchDB generates an Id for a new document, will  
> it make sure that ID doesn't exist first?  I know the chances of  
> generating the same exact ID are slim to none, but the question  
> still remains.

According to the documentation on the Wiki, POSTing to _uuids  
retrieves a list of *unused* document IDs, so one would assume that it  
does check to ensure the ID doesn't exist.

However, from reading the code it looks like *no* checks are actually  
made (either when POSTing to _uuids or when POSTing to save a document  
with autogenerated ID), but given that the UUID is securely randomly  
generated the chances of a collision are so slim there is no point  
worrying about it (see

.  If a collision does occur, then I think all that would happen is  
you would get a document update conflict error, perhaps someone more  
familiar with the internals can confirm this?

Jason Davies

View raw message