launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #04056
Re: tuesday - performance day!
On Tue, Aug 3, 2010 at 10:18 PM, Julian Edwards
<julian.edwards@xxxxxxxxxxxxx> wrote:
> On Tuesday 03 August 2010 11:02:03 Robert Collins wrote:
>> So what apparently happens here (this is where Tim helped out :)) is
>> that lazr.restful is introspecting *every declared attribute*; so we
>> have 'allmembers' which is a person property that does a (fairly
>> cheap) query, and then that cheap query is expanded item by item,
>> property-by-property. (Oh, and hint for finding the right method -
>> grep for 'exported_as.*URL_SUFFIX' - e.g. exported_as.*participation -
>> in the interfaces files.
>
> The lesson is, don't hide complicated queries behind @property! I've
> converted some of IArchive's properties to methods before to stop them getting
> queried when the webservice introspects the attributes.
Many of the queries are very simple. e.g. 'has the person signed any
version of the CoC'. The problem is that when you have 40 people, that
means 40 queries. The +participation page that triggers the same
method does *800* queries.
> I'm intrigued as to this apparent recursiveness you describe though? Or am I
> misunderstanding?
inner level: person.karma
outer level: generator of people
So the API hits
person.allmembers
which returns a generator (a resultset containing all the members
(one, cheap, query))
lazr.restful then does (psuedocode):
result = []
for person in generator:
result.append(to_json(person))
and to_json(person) does:
properties = {}
for attribute in interfaces_of(person):
properties[attribute] = getattr(person, attribute)
and that triggers a separate query for 'coc_signed', 'karma',
'emblems', 'packages_built' etc etc.
It doesn't recurse any deeper than that though, fortunately!
-Rob
Follow ups
References