[Zope-dev] Re: ZOBD and pointers

Laurence Rowe l at lrowe.co.uk
Mon Jun 20 09:11:45 EDT 2005


As far as I am aware, ZODB will store a list of pointers to the lists of 
z objects. What you should be careful of for efficient use of ZODB is 
that your list is stored in an efficient way, well if the list is 
updated often or long anyway.

When you pack your ZODB does it take up a lot less space? If so it may 
be that a lot of space is being wasted storing the updated lists of 
object references. Unless you use a special PersistentList ZODB will 
have no choice but to store a new copy of the whole list when that list 
is modified. If you have long lists then this can be a big problem. The 
Persistent classes have special handling to make them more efficent.

So instead of lists use PersistentLists and instead of dicts use BTrees, 
as these may be stored more efficiently in the ZODB.

Also have a look at the analyze.py script to try and track down where 
the space is being used. My notes here may be helpful too 
http://zopelabs.com/cookbook/1114086617

Hope that helps,

Laurence

Yair Benita wrote:
> Hi All,
> 
> As my ZODB data files become larger and larger I am looking at ways to make
> the structure of my objects more efficient. To simplify my question, suppose
> I have two different classes and both contain a list of a objects from a
> third class:
> 
> class x has the attribute x.elements = [objects of class z]
> class y has the attribute y.elements = [objects of class z]
> 
> As far as I understand python the lists x.elements and y.elements contain
> pointers to the z objects previously defined. What I wanted to know is how
> ZODB handles that (or maybe I should say: how pickle handles that) when
> saving to a file. Will the pointers be converted to a copy of the z class
> objects or will one copy of the z class objects be saved and than the
> x.elements and y.elements will still be a list of pointers?
> 
> Thanks for the help,
> Yair



More information about the Zope-Dev mailing list