Re: CoreData performance issues
Re: CoreData performance issues
- Subject: Re: CoreData performance issues
- From: Chris Hanson <email@hidden>
- Date: Tue, 21 Jun 2005 22:29:02 -0700
On Jun 21, 2005, at 5:10 PM, Tomek Piatek wrote:
We have written a simple test application which reads in a line at
a time from the text file and for each record creates a managed
object instance. The managed object context is saved only once
after all records have been processed. We want to avoid duplicates
and in fact we want to reuse existing managed objects. For example,
when ingesting a new scene we want to create a new project object
only if one with the given name doesn't already exist.
It sounds like what you're doing is something like this:
1. Read a line of input.
2. Decide which entity to instantiate for it.
3. Execute a fetch request to see if an instance with that name
already exists.
a. If it does, do nothing.
b. If it doesn't, create it.
4. Connect its relationships.
5. Repeat.
This isn't the most efficient way to do this kind of batch import.
Most importantly, don't issue fetch requests for step 3. Instead,
just keep track of the objects you create during the import by name
in a dictionary. If you can run subsequent imports, then do a fetch
once at the very beginning to "prime" your dictionary, and use that
to determine uniqueness for the rest of the import.
-- Chris
_______________________________________________
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