Growing database?

David M. Cooke cookedm+news at physics.mcmaster.ca
Tue May 4 13:48:11 EDT 2004


At some point, Jonathon McKitrick <jcm at FreeBSD-uk.eu.org> wrote:

> This might be a silly question, so I'm warning you ahead of time.
>
> I have a persistence database that is saving a 'month' object out with its
> data.  A single month pickled is about 50k.  My database of shelved objects
> contains 4 months of data is over 3 megs.  Does the db object journal, or do
> some other recordkeeping that could explain the huge size difference between
> pickling to a file and pickling to a 'shelve'?

Depends on what db module shelve uses for its backend. For instance,
gdbm won't shrink a database file unless you specifically tell it to,
so if you have a lot of deletions it will grow.

Easiest way to fix it is to copy all the objects from your shelve to a
new shelve.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list