[ZODB-Dev] ZODB and ORBit-Python problems

Jim Fulton jim@digicool.com
Mon, 21 May 2001 16:45:42 -0400


Christian Robottom Reis wrote:
> 
> On Sat, 19 May 2001, Jim Fulton wrote:
> 
> > Christian Robottom Reis wrote:
> > >
> > > On Fri, 18 May 2001, Jim Fulton wrote:
> > >
> > > This makes perfect sense. However, at times, an application has to do
> > > things both ways: use objects interactively with it's interface, loading
> > > and using objects as needed; and generate summaries from information
> > > contained in a series of objects.
> >
> > I don't think I understand you. I don't see what the above had to do
> > with loading *all* the objects from the database.
> 
> Sorry for being imprecise. I don't mean, necessarily, _all_ objects in the
> database; let's assume I have a collection of objects representing
> Sales (textbook example) that reference Employee objects. If I want to
> summarize how much employees sold, I either have to keep an autocalculated
> attribute, or generate a summary, in which case I _must_ load all objects
> from the database, and calculate the totals. So while sales are generates
> individually, summaries have to load all of them.

Do employees keep track of their sales? Or do you have a collection of sales?
Where are sales stored? Loading the entire database to get a subset of the objects
seems like a bad thing.

> Following up on the last reply (since the matters are connected), I wonder
> when (if?) memory will be freed for them in time, and if there is
> something that can be done to let ZODB know we won't be needing it
> in-memory for the moment.

The cache periodically looks for objects that haven't been used in a 
while and can become ghosts and for objects that are no longer
referenced. It does this when the connection is closed, when transactions
that modified objects are committed, and when the connection sync method
is called.

You can explicitly request an object to become a ghost by calling it's
_p_deactivate method. You can also call methods on the connection to cause
it to perform gc on it's cache.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org