Re: Core Data performance advice... creating relationships.
Re: Core Data performance advice... creating relationships.
- Subject: Re: Core Data performance advice... creating relationships.
- From: Martin Linklater <email@hidden>
- Date: Tue, 15 Jan 2008 23:49:53 +0000
Martin,
Looking at the Instruments snapshot, one can see most of the time is
spent maintaining the inverse relationship as that is triggering
faulting of unloaded data.
When you dirty a managed object for the first time, we need its
current data to establish a snapshot. The snapshot is used for
several features including undo, merge policies & conflict
detection, and the committedValuesForKeys/changedValues methods.
This includes the identities (but not full data) of object's current
relationships.
For to-many relationships, this can trigger additional faulting (in
database terms, a fetch against the join table)
You can address the problem by prefetching Foo's to-many
relationships during your initial fetch. If Bar has other to-many
relationships, you'll want to prefetch those in the fetch request
for "bar where ID = X"
The Instruments set you used doesn't include all the Core Data
instruments from the main template, specifically "Core Data Cache
Misses", so Instruments isn't high lighting the specific problem as
well as it could.
If you add that instrument, you should see both the entity and
relationships that are being faulted.
Thanks Ben. I'll take your comments on board and see if I can't speed
things up.
Cheers.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden