Using setRelationshipKeyPathsForPrefetching doesn't trigger a prefetch

Hey,


I'm expriencing a strange issue, same as the one described inthis SO question - I configure a NSFetchRequest using setRelationshipKeyPathsForPrefetching to trigger a prefetch for 2 relationships - first is one to one, the other is one to many. When I use the com.apple.CoreData.SQLDebug launch argument I see that the prefetch isn't happening, and instead faults are fired every time I access the relevant property, thus turning what was supposed to be one db fetch into approximately 30. I've tried everything and couldn't make this work for more than a day now.


Practical example (taken from the afore mentions SO question):

    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:[NSEntityDescription entityForName:entityName inManagedObjectContext:context]];
    [request setPredicate:[NSPredicate predicateWithFormat:@"index == %@",index]];
    [request setFetchOffset:offset];
    [request setRelationshipKeyPathsForPrefetching:@[@"sender",@"attachments"]];
    [request setIncludesSubentities:YES];
    [request setReturnsObjectsAsFaults:NO];


Did anyone see this behaviour before? This adds quite a bit of overhead to all Core Data operations.

Appreciate your help and insights!

Are those sender and attachments valid properties on the Core Data Entity? Double check the value of the entityName variable, just to make sure the fetch request is 100% valid. Is it possible to share the SQL Debug output at level 3?

Same problem here, did you figure it out?

Using setRelationshipKeyPathsForPrefetching doesn't trigger a prefetch
 
 
Q