• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Performance degrades dramatically in [NSManagedObjectContext executeFetchRequest:error:]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Performance degrades dramatically in [NSManagedObjectContext executeFetchRequest:error:]


  • Subject: Performance degrades dramatically in [NSManagedObjectContext executeFetchRequest:error:]
  • From: "Oleksiy Gorelov" <email@hidden>
  • Date: Fri, 06 Mar 2009 21:58:24 +0200

Hello All!

(this is the same in plain text)

Summary: It looks like [NSManagedObjectContext executeFetchRequest:error:] starts to evaluate a predicate ([NSPredicate evaluateWithObject:]) with objects that was not requested and was not fetched from
a database.

Our application makes prefetching of CoreData entities with relationships like

NSFetchRequest* requestRelatedTags = [[[NSFetchRequest alloc] init] autorelease];
[requestRelatedTags setEntity:[NSEntityDescription entityForName : kFSIValueElementA inManagedObjectContext : [md managedObjectContext ]] ];
[requestRelatedTags setFetchLimit: 1000000 ];
NSPredicate * predicate = [ NSPredicate predicateWithFormat: @"(self IN %@)",[items valueForKey: @"objectID"]];
[requestRelatedTags setPredicate:predicate];
[requestRelatedTags setRelationshipKeyPathsForPrefetching : [ NSArray arrayWithObjects: @"tags", nil]];
[requestRelatedTags setReturnsObjectsAsFaults: true];
items0_ = [[md managedObjectContext] executeFetchRequest : requestRelatedTags error: nil];

where "items" is an array of 100 NSManagedObjects, "tags" is to-many relationship of the kFSIValueElementA entity with inverse to-one relationship.

At start this code works quickly and takes fixed amount of time (0.03-0.04 sec) every time. But at some point it starts to work very slowly taking more and more time. Instruments shows that it fetches 100 objects
every time from a database. But Shark shows that it uses [NSPredicate evaluateWithObject:] more and more times. To be precise, it invokes [NSPredicate evaluateWithObject:] 100 times more every time.
[NSPredicate evaluateWithObject:] is invoked every time from [NSManagedObjectContext executeFetchRequest: error:].

We added logging to [NSPredicate evaluateWithObject:] and we see that it is evaluated on objets that was not requested by the fetch request and was not fetched from the SQLite database. Thus this is a bug
in [NSManagedObjectContext executeFetchRequest:error:]. It should not filter objects that was not.

Does anybody have any ideas how to solve this problem?

Best Regards,
Oleksiy Gorelov
_______________________________________________

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

  • Prev by Date: Performance degrades dramatically in [NSManagedObjectContext executeFetchRequest:error:]
  • Next by Date: Re: A question about NSPredicateEditor and NSPredicateEditorRowTemplate
  • Previous by thread: Performance degrades dramatically in [NSManagedObjectContext executeFetchRequest:error:]
  • Next by thread: re: Performance degrades dramatically in [NSManagedObjectContext executeFetchRequest:error:]
  • Index(es):
    • Date
    • Thread