Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
- Subject: Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
- From: email@hidden
- Date: Tue, 20 Dec 2005 19:21:32 -0800
Might try to check the amount of relationships that need to deleted
and nullified by the original delete.
It might be complex, in which case there is not much to do except
hope for performance update or
maybe change your object model...
One thing, that *may* be slightly fast would be to call the raw C
array and cycle through that like: (THIS IS UNTESTED!!)
///////////////////////////////
id undoManager = [[context undoManager] retain];
int numberOfObjectsToDelete = [objects count];
id arrayOfObjectsToDelete = [objects
getObjects:&arrayOfObjectsToDelete];
int currentObject = 0;
while (currentObject =0; currentObject < objectsToDelete;
currentObject ++)
{
[context deleteObject:objectsToDelete[currentObject] ];
}
[context setUndoManager:[undoManager autorelease]];
//////////////////////////////// Might give you 3 or 4 seconds
faster... thats
Maybe the NSManagedContext should have a - (BOOL)deleteObjects:
(NSArray *)objects method, that way
the context can analyze the relationships in relation to eachother
and speed the delete....
Simon Liu wrote:
I have a tableview representing managed objects. If I select all the
managed objects e.g.10,000, and delete them from the
managedObjectContext, there is a long delay e.g. 30 seconds.
Is there a way to delete large numbers of objects from a context
quickly and avoid the spinning beach ball? I don't really want to
have to delete the objects in a background thread, or put up a panel
saying 'Deletion in progress'.
My managed objects have relationships with nullify and cascade
deletion rules. My deletion code looks something this:
id undoManager = [[context undoManager] retain];
[context setUndoManager:nil];
while (obj = [enumerator nextObject]) {
[context deleteObject:obj];
}
[context setUndoManager:[undoManager autorelease]];
Appreciate any tips. Thanks.
--Simon
_______________________________________________
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
_______________________________________________
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