Re: too many database conflicts when using ZODB with int ids and indexes
Jim Fulton <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <CAPDm-Fi9MoPjNgcyvUFm+Cji+b8Ztcmn5nZ-RMk1i11wF6pcqA@mail.gmail.com> |
On Fri, Nov 11, 2016 at 8:12 AM, Sanjay Rao <[email protected]> wrote: > How can we say that zc.initid is better than zope.app.intid with respect > to conflict handling ? > > zope.app.intid basically creates a hash like this to choose bucket: > > def __hash__(self): > return hash((self.object._p_jar.db().database_name, > self.object._p_oid, > )) > No. It doesn't. BTrees are based on ordering. It uses the database name and oid for comparison. > > Where as zc.intid stored int id as an attribute of object itself and keeps > only one mapping from intId -> object. > > How zc.intid is avoiding/minimising conflicts > or > let me ask this way: How persistent key -> intid mapping was more conflict > prone than intid->object mapping ? > KeyReferenceToPersistent uses database name and oid for comparison and thus BTree keys. Because oids are allocated sequentially, concurrent transactions are likely to be operating on the same BTree buckets. Leading to lots of conflicts. Most of these conflicts can be resolved, however, even resolved conflicts are bad because they cause extra work during commits. Many of these conflicts can't be resolved because some of the transactions are causing bucket splits and bucket conflict resolution doesn't work in the presence of splits. Jim -- Jim Fulton http://jimfulton.info -- You received this message because you are subscribed to the Google Groups "zodb" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.