[ZODB-Dev] Finding objects by attribute value?

Christian Robottom Reis kiko at async.com.br
Wed Dec 29 08:07:24 EST 2004


On Wed, Dec 29, 2004 at 01:16:46AM -0500, Leif K-Brooks wrote:
> If my dbroot['foo'] contains an OOBTree where the values are object 
> which have an attribute called "attr", what's the best way to get a list 
> of the objects whose "attr" attribute is equal to a certain value, along 
> the lines of SQL "SELECT * FROM foo WHERE attr=123"? The most obvious 
> method is [obj for obj in dbroot['foo'].iteritems() if obj.attr == 123], 
> which gets decent performance for FileStorage, but the performance is 
> terrible with ZEO (most likely due to transferring all of those objects 
> over the network). What's the correct way to achieve the result I want?

I'd suggest taking a loot at IndexedCatalog, which offers indexing and
[non-unlimited-but-often-sufficient] query capabilities. Johan has done
some work to getting us ZODB 3.3-ready, and there is a branch you can
pull from Async CVS to see that work, or just grab the latest release
and use ZODB 3.2.

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331


More information about the ZODB-Dev mailing list