[ZODB-Dev] Basic ZODB practices
Martijn Faassen
faassen at infrae.com
Tue Mar 9 12:43:40 EST 2004
John Belmonte wrote:
> Hector Sanchez SanMartin wrote:
>
>> I'm using ZODB and I need to minimise ConflictErrors in my
>> application so I would like to describe my situation and ask for some
>> ideas about how could improve it (if possible) in order to minimise
>> ConflictErrors as I'm sure you have already faced the same problem.
[snip]
>
> The first course is to avoid sequential ID's completely. You can use
> Python's rand library to generate a random ID. Before inserting an
> object into your collection, verify that you don't have an ID collision.
> Collisions should be extremely rare if you use an ID size such as 64
> bits. The BTree will also benefit from having random keys, as this will
> minimize write conflicts caused by shuffled buckets.
Just out of curiosity:
You'd think random ids could be *bad* for read performance though. If
there is some sequentiality in the data you're putting in a BTree, and
you're reading this data in its 'native' sequencing, with random ids
you'd be waking up a lot of buckets, which hurts read performance.
Better just wake up a single bucket with the sequential data in there,
and then read the values. What're people's thoughts on this?
Perhaps related, I recall Tim Peters (I think, might've been someone
else) once (long ago..) saying random ids don't really help, though I
forget the exact context. Perhaps Tim remembers and can jump in, but I
may remember this completely wrong anyway. :)
Regards,
Martijn
More information about the ZODB-Dev
mailing list