[Chandler-dev] help in resolving the filters-loading-items problem
Grant Baillie
grant at osafoundation.org
Mon Jun 12 17:23:07 PDT 2006
On Jun 12, 2006, at 16:23, Andi Vajda wrote:
> A long standing performance bug is that some filter expressions
> used by FilteredCollections use an expression that causes the
> entire item (or more) to be loaded. Normally, this is not a problem
> but it becomes one when the collection becomes part of another
> collection and an index is created from scratch on the new
> collection causing all the collections making it up to be iterated
> for item UUIDs. For a FilteredCollection to return an member item's
> UUID, it needs to first test whether the item is a member (unless
> it has an index of its own) and that can cause the item (and
> whatever else the filter expression needs to run) to get loaded.
>
> There are currently two collections in the Chandler source that
> still use regular attribute access (hence loading the item) instead
> of view.findValue(). This is because their filter relies on several
> other items to come up with a True or False answer.
>
> To resolve this, I proposed a 'bequeatheTo' feature which is like
> 'inheritFrom' but in reverse. Whenever a value in such an attribute
> changes, the attribute(s) mentioned in its 'bequeatheTo' aspect
> would be given that value as well. That way, these values could be
> cached on the item being tested by the FilteredCollection, allowing
> view.findValue() use thereby preventing the item from being loaded.
So, after some further discussion, it turns out bequeathTo isn't need
here. There are 2 cases (of using view[] instead of view.findValue
(s)) in parcels/osaf/__init__.py:
(1)
eventsWithRemindersIncludingTrash = FilteredCollection.update(
parcel, 'eventsWithRemindersIncludingTrash',
source=events,
filterExpression="getattr(view[uuid], 'reminders', None)",
filterAttributes=['reminders'])
(2)
masterFilter = "view[uuid].hasTrueAttributeValue('occurrences')
and "\
"view[uuid].hasTrueAttributeValue('rruleset')"
masterEvents = FilteredCollection.update(parcel, 'masterEvents',
source = events,
filterExpression = masterFilter,
filterAttributes = ['occurrences', 'rruleset'])
The "view[uuid].hasTrueAttributeValue('rruleset')" case can be dealt
with by the existing findValue(). The other two cases ('occurrences'
and 'reminders') are trying to figure out if a refcollection is empty
or not. So, Andi is going to add some API to the repository layer to
do just that.
--Grant
More information about the chandler-dev
mailing list