On Tue, Apr 6, 2010 at 2:42 AM, Leszek Syroka
> I am optimizing an application in which fetching objects from the ZODB
> seems to be a bottleneck. The problem is I would like to fetch an object
> that contains some persistent fields. For example:
> class A (Persistent):
> def __init__(self):
> self._primaryAuthors = PersistentList()
> self._coAuthors = PersistentList()
> self._speakers = PersistentList()
> After that there is a need to fetch every single persistent field
> (_primaryAuthors , _coAuthors, __speakers etc. ) from this object,
> which takes a lot of time. It seems that access time to the ZODB takes
> significantly more time than operations performed inside the database to
> load an object.
Were you using ZEO? Uncached ZEO loads take far longer that loading
data from a local database, or from a ZEO cache.
> Is there a possibility to fetch an object and its all
> persistent field with a single access to the ZODB?
No, not currently.
> Changing fields to
> non persistent is rather impossible due to complications in the
> application's architecture.
In the future, I plan to add support for persistent objects that
share database records, allowing multiple objects to be loaded
at once to address use cases like yours.
For more information about ZODB, see the ZODB Wiki:
ZODB-Dev mailing list - ZODB-Dev@zope.org