re: Core Data performance advice... creating relationships.
re: Core Data performance advice... creating relationships.
- Subject: re: Core Data performance advice... creating relationships.
- From: Ben Trumbull <email@hidden>
- Date: Tue, 15 Jan 2008 14:50:30 -0800
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.
--
-Ben
_______________________________________________
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