Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
- Subject: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
- From: Javigator <email@hidden>
- Date: Fri, 15 Jul 2005 10:30:58 +0200
Hi everybody,
I currently developing a CoreData based application which mainly
consists of two entities which are connected with a to-many
relationship. Entity1 populates a table when Entitiy2 is selected in
another table. All this is done using bindings an NSArrayControllers.
For data storage I use the CoreData SQLite store.
Now to the problem: performance.
At some point in the application there's some data generation which
initially is in the form of nested NSArrays. Top level array consists
of around 600 NSArray objects, all of them containing 11 objects
(they correspond to the attributes of Entity1). The goal is to
convert this into CoreData entities to be stored and displayed in a
table.
My current implementation looks simple and is working: Loop over
those 600 objects, create an entity using NSEntityDescription
insertNewObjectForEntityForName:inManagedObjectContext: and fill in
the data using setValue:forKey: for each of the attributes of the
entity. Additionally set the relationship to the currently selected
Entity2 object.
But on my PowerMac G5 1,8 SP (1st gen.) with 1,5 GB this conversion
takes over 30 seconds - and that's without saving the data store! I'm
really stunned because of this bad performance... I was thinking that
the object creation shouldn't take more than one to three seconds.
That leads to the question why this is so slow? Is there a faster way
to do it? In creating the objects? Or fill in the data? Or is it
because there's a NSArrayController sitting and simultanously adding
these objects to its data structure and a bound NSTableView trying to
keep up with displaying the incoming new data (what, in fact, still
takes some more seconds (the display of the data))? If so, is there a
clever way to speed things up?
Because, with this kind of bad performance (in case I made nothing
wrong and work like intended), CoreData seems to be in no position to
deliver industrial strength speed for applications with more than
hundreds of objects to manage. That doesn't seem to justify the work
Apple put into this framework, which leads me to think that I'm
overlooking something important, maybe obvious, to help me out of
this performance hole.
Please enlighten me! :-)
Best regards,
Joern Janoschek.
_______________________________________________
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