[ZODB-Dev] Find references to an object

Greg Ward gward@mems-exchange.org
Mon, 6 Aug 2001 21:01:43 -0400


ZODB gurus --

given an OID, is it possible to find all objects that reference that
object?  Ideally I would like to do this without crawling the entire
database and loading every object, but I doubt that's possible: ZODB
doesn't index, and how can you do this kind of reverse query without an
index?  (Our database is currently only about 40 MB and 130,000 objects,
so crawling the whole thing isn't out of the question.  It's just
inelegant.)

Perhaps what I'm looking for is this: a sneaky, underhanded way to load
object A, find the list of all objects (OIDs) it references, and see if
object B is in that list.  If so, add object A to the list of objects
referencing B.  Repeat database.objectCount() times.  The problem I see
with this is how to deal with extension types like BTree, which
reference lots of objects in an opaque way.

Any suggestions?

        Greg
-- 
Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange                            http://www.mems-exchange.org