views:

64

answers:

3

A general CoreData/SQLite question

Is there a significant difference between these two scenarios when saving a NSManagedObjectContext using an SQLite store:

  • After adding/changing/deleting one object in a NSManagedObjectContext containing 10 otherwise unchanged NSManagedObjects
  • After adding/changing/deleting one object in a NSManagedObjectContext containing 10'000 otherwise unchanged NSManagedObjects
+1  A: 

Profiling will tell you if there's a significant difference. However, I suspect that the type of the store coordinator will affect the performances. Updating an object in a SQLite database is probably faster and more scalable than doing so in a XML tree.

Martin Cote
I would be most interested in real-world experience using SQLite. Obviously I could build a fake database with fake content to see the difference... but that would take long ;)
Felix
A: 

In my previous experience there is not a significant difference. If the object being added/changed/deleted contains a lot of indexed attributes, then it will take just slightly more when compared to the case of an object with no indexed attributes, but this is expected since indexes will also be modified as well.

unforgiven
thanks, good to know indexing plays a role. I didn't really think of that, but makes perfect sense.
Felix
+1  A: 

Generalizing from my experience with Enterprise Objects (which Core Data evolved from) I would say that both of your scenarios would be equally fast without indexing and the second slightly slower with indexing.

Using and SQL store, the cost of adding one object is largely fixed regardless of how many other objects are in the graph. Indexing does cause a scaling effect because the index is dependent on other existing objects. However, in the vast majority of cases, this is not significant.

The more complex the relationships within the graph the more saves are impacted by total graph size. Obviously, if you have graph with only ten objects, then no relationship can have more than ten objects in it. If you have one with 10,000, the relationships are potentially much larger and take longer to process.

In sum, Core Data with an SQL store appears to be largely unaffected by just the size of the graph.

TechZen
thank you for a very clear and differentiated answer.
Felix
If this is the best answer, hit the check mark to the side so that the system knows the question has been answered and that I can get those sweet, sweet rep points.
TechZen
Sorry, I must have been sleeping. Had a busy day yesterday and forgot to check this.
Felix