• 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
[COREDATA] fetchRequest performance problem, any advice ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COREDATA] fetchRequest performance problem, any advice ?


  • Subject: [COREDATA] fetchRequest performance problem, any advice ?
  • From: AurĂ©lien HugelĂ© <email@hidden>
  • Date: Thu, 26 Jan 2006 16:40:21 +0100

Hi everybody !

i have a very simple fetchRequest that is very long to execute (ok, only 1.5s on my 2x2Ghz G5 with tons of ram, but it is stunningly slow for that simple request) and i would like advices to improve the execution time :

i have some persons that have phone calls, so there is a to-many relationship between Person entity and Call entity.
A Call may be "alone" and not linked to any one.
A Person may exist and have no calls.


i need to find all the persons that have at least one phone call linked to them

my fetch request is then defined as this :

NSFetchRequest* fr = [[[NSFetchRequest alloc] init] autorelease];
[fr setEntity:[NSEntityDescription entityForName:@"Person" inManagedObjectContext:[self managedObjectContext]]];
[fr setPredicate:[NSPredicate predicateWithFormat:@"calls.@count > 0"]];
NSError* error;
persons = [[self managedObjectContext] executeFetchRequest:fr error:&error]; // slow fetch request!
if(!persons)
NSLog(@"%@, %@ error:%@",[self class],NSStringFromSelector (_cmd),error);



i have *only* 3745 persons in my database and about 150 calls.
the fetch request takes 1.5s to be executed (only 27 persons are returned!) on one of the fastest mac today!!!! and every thing has already hit cache, so no fault is fired (the calls and the persons).


I'm pretty sure the predicate is responsible for this slowness, using the @count array operator is probably not very SQL friendly... and not very optimized.

Can any one gives me any hint to rewrite my request, use another predicate, or any other idea to improve this surprisingly slow fetch ?

thanks

Aurelien



_______________________________________________
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


  • Prev by Date: Re: Bindings or datasource for a large NSTableView
  • Next by Date: Re: I think I have found a big bug in NSBrowser
  • Previous by thread: Re: NSFileManager and Finder disk usage discrepancy
  • Next by thread: utility panel and document based
  • Index(es):
    • Date
    • Thread