[ZODB-Dev] Finding objects by attribute value?

Chris Bainbridge chris.bainbridge at gmail.com
Fri Jan 7 11:16:05 EST 2005


On Wed, 29 Dec 2004 01:16:46 -0500, Leif K-Brooks <eurleif at ecritters.biz> 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 had a similar bandwidth problem and solved it by running a client on
the server which connects to localhost, and then allowing only that
client to carry out the heavy work (the code is the same, but does 'if
hostname == something: connect_to_localhost ... if
connected_to_localhost: do_stuff ...'). It helped, but would have been
faster if I could've figured out how to get zodb to listen for client
connections on a unix socket and tcp at the same time (is it
possible?).


More information about the ZODB-Dev mailing list