Couchdb exhibits extremely beneficial performance gains by using sequential ID's. However, there is something to be said for being able to instantaneously "know" the ID of an object simply by looking at the content (for example hashing a user name into an ID). How can I more or less achieve the convenience of the hashed ID, yet the performance gains of sequential ID's.
preguntado el 08 de enero de 11 a las 21:01
I don't think a workaround is possible.
View key lookups are only a tiny bit slower than document id lookups. (See los puntos de referencia.) My understanding is that the type of document
_id does not impact performance in the case of a view lookup because it relies on its own independent B-tree structure. So for actually looking up user information, view lookups over sequentially-identified documents are totally fine.
But I understand that you would like to be able to register users and guarantee that there can be no username conflicts. So you DEBE have the username in the document id.
This is the appropriate thing to do if you decide to rebel against CouchDB's eventual consistency approach.
Also, my understanding is that you are not likely to experience degraded performance unless you are doing bulk inserts of random usernames or handling a high number of new user registrations per second.
This is the same performance trade-off other databases make. You can insert data faster without locks/transactions than you can by imposing them.