[ZODB-Dev] Approaching the ZODB
Christian Reis
kiko@async.com.br
Thu, 20 Jun 2002 08:11:00 -0300
On Thu, Jun 20, 2002 at 02:28:25AM -0700, Michael Casaday wrote:
> I'm just getting to know the ZODB. I'm tempted to take a really
> hierarchical approach to the database for my app, where objects own
> objects which own lots of other objects etc etc. This seems like a
Hey, that's the really fun part about working with the ZODB :-)
> on how the ZODB works. I'm wondering if anyone here can assuage my
> misgivings.
Well, our project uses the ZODB where a relational database would
normally be used, so I have an idea. Just as a starter, what kind of
application are you developing?
> Say I have persistent classes Author, Book, and Page. Author's have a
> relatively short list of Books. Books have a relatively large number
> of Pages, kept in an IOBTree. Pages are fairly small memory-wise by
> themselves, but if you added up all the Pages in a typical Book you
> would have a collection of objects large enough to make you think
> twice about loading them all up in memory. Ideally you would only
> want a few Pages in memory at any given time.
Not all objects will be in memory; the ZODB keeps putting them to sleep.
So unless you're touching all objects at the same time, memory
consumption can be kept quite low.
> Let's say my databases's root is a dictionary of Authors. If I pull
> an Author from the database, and that author has a few Books, and each
> of those books have a whole bunch of Pages, does the ZODB pull the
> whole mess into memory? ^^^^^^^^^^^^^^^^^^^^^^
> ^^^^^^^^^^^^^^^^^^^^^^^
Nope!
> Would it be wiser to take a more relational database-esque approach,
> and use IOBtrees to index all of the Pages, Books, and Authors by some
> unique ID number? In this approach there might be IOBtrees called
> 'books', 'authors', and 'pages'. An Author, instead of having a list
> of Book objects (like in the first example), would instead have a list
> of integers corresponding to the keys of its Books in the 'books'
> IOBtree.
This is a solution to other problems (sharing objects between multiple
ZODBs until we come up with cross-ZODB references *WINK*) but for your
application, not really.
One performance issue you might want to consider, if your application
really is books and authors and so on, is querying and indexing, which
the ZODB doesn't provide inbuilt. We're working on a ZODB query/index
solution, and the code is almost ready for a 0.01 release, so stay tuned
(Johan!).
Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL