Re: CoreData deleteAll of kind
Re: CoreData deleteAll of kind
- Subject: Re: CoreData deleteAll of kind
- From: Mike Abdullah <email@hidden>
- Date: Tue, 7 Jul 2009 01:19:50 +0100
On 6 Jul 2009, at 23:37, Devraj Mukherjee wrote:
Thanks all for your feedback. Seems quite inefficient. Wonder if this
is filed as a suggestion to Apple.
Why should that matter? File a request anyway, it will make the
existing request ore prominent.
There are two reasons to have a batch API generally: convenience and
performance. If after all this time there is still no batch deletion
API for Core Data, it is almost certainly because no-one has found it
to be a performance bottleneck that could be improved by a batch API.
Consider the work required by a deletion:
- Validate the object for deletion
- Internally mark the object as as deleted internally
- Any applicable relationships cascaded or nullified
- Add to the undo stack
Would a batch API really be significantly faster than iterating the
objects yourself? (disclaimer: I don't know) Particularly since those
changes are all in-memory; deleting objects from the persistent store
only happens upon a -save: which is effectively a batch operation of
itself.
Finally, the whole validation issue is an important one. An object can
refuse to be deleted because certain criteria are not satisfied. In
your proposed -deleteObjects: API, how would it deal with some objects
agreeing to be deleted, but others not?
As ever, the golden rule: Write the easiest code you can first. If it
turns out to be a performance issue, profile it and figure out why. If
the bottleneck really isn't one you can fix, rework the design and
file a bug report.
Mike.
_______________________________________________
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