On Apr 2, 2009, at 4:19 AM, Adam GROSZER wrote:

> Hello,
> What's a good practice to create unique container keys for a heavily
> loaded application? (I mean lots of writes to the same container)
> Obviously having a counter on the container and incrementing and using
> that for key gives write conflicts.
> What do the experts use?

Assuming that ordering of the keys isn't important, my favorite  
strategy is to:

- use integer keys, which saves memory and makes lookup faster if you  
use an IOBTree.
- assign keys sequentially with random starting points, using a _v_  
variable to keep track of the index. The idea is that instances in  
separate threads/processes use different random starting points, to  
avoid conflicts, but assign keys sequentially to update the btree  

See for example _generateId in:


Jim Fulton
Zope Corporation

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to