coredata batch fault/prefetch relationships
coredata batch fault/prefetch relationships
- Subject: coredata batch fault/prefetch relationships
- From: Jesse Grosjean <email@hidden>
- Date: Tue, 24 Jan 2006 09:21:40 -0500
I'm sorry if these questions are already answered in the
documentation (Core Data Programming Guide: Fetching Managed
Objects), I'm just having a hard time putting it all together.
I have a tree structure in core data and I'm trying to figure out the
best way to pre-fetch the entire structure along with all
relationships (except for the valueHolder relationship). My tree
structure consist of lightweight Nodes entities. The nodes don't have
any attributes, but they do have three relationships:
Node
parent (to one relationship to Node)
children (to many relationship to Node)
valueHolder (to one relationship where actual values are stored)
The first thing that I do is try to batch fault all Node entities
using this code from the Core Data Programming Guide.
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Node"
inManagedObjectContext:moc]];
fetchResults = [moc executeFetchRequest:fetchRequest error:&fetchError];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"self IN
%@", fetchResults]];
[moc executeFetchRequest:fetchRequest error:&fetchError];
But that still leaves all the relationships in the fault state, and
firing the faults on the parent and children relationships is a big
performance problem. If I add the following two lines to the above
code my application will run fast after the two lines have executed,
but executing these two lines takes a very long since I've just
manually firing the relationship faults.
[fetchResults valueForKey:@"parent"];
[[fetchResults valueForKey:@"children"] valueForKey:@"parent"];
So my big question is how to I pre-fetch these relationships
efficiently? The Pre-fetching example in the documentation looks like
it's pre-fetching the destination objects, but not the relationship.
In my case the destination objects have already been fetched, but the
relationship between the source and destination is still faulted. Is
it possible to also pre-fetch those relationships?
Thanks,
Jesse
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden