Re: coredata and loooooooooooooooong waits
Re: coredata and loooooooooooooooong waits
- Subject: Re: coredata and loooooooooooooooong waits
- From: Benjamin Salanki <email@hidden>
- Date: Tue, 17 Oct 2006 11:18:11 +0200
I am in fact using an SQL store, and I originally used this code:
NSManagedObjectContext * moc = [[NSApp delegate] managedObjectContext];
NSEntityDescription * entityDescription = [NSEntityDescription entityForName:@"SCEntity" inManagedObjectContext:moc];
NSFetchRequest * request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entityDescription];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"storeID.storeID = %d", [[store valueForKeyPath:@"storeID"] intValue]];
[request setPredicate:predicate];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"clipID" ascending:NO];
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];
NSArray* result = [moc executeFetchRequest:request error:nil];
and this is where I first got the responses that it was taking too long. After this I changed to the approach of going from the store side of things rather than the item side.
Ben
On Tuesday, October 17, 2006, at 11:10AM, Jakob Olesen <email@hidden> wrote:
>
>On 17/10/2006, at 10.54, Benjamin Salanki wrote:
>
>> But if I do it this way it will read through all the clips, which
>> can be in the thousands, rather than all the stores, where there's
>> only 5 max. Or am I not getting this right?
>
>In theory, yes, but Core Data creates indices for all the
>relationships, so SQLite is able to use an index for that query.
>It is pretty much the same query Core Data is using internally when
>you say [store valueForKey:@"storeClips"]
>
>Alternatively, you can do a batch fault with a predicate "SELF in %
>@", [store valueForKey:@"storeClips"]
>
>This is only true for the SQLite store. The XML store will be slow,
>it has no indices.
>
>
>
>
_______________________________________________
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