1

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

3 Answers 3

2

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.

2
  • 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
    Feb 9, 2010 at 19:53
  • Sorry, I must have been sleeping. Had a busy day yesterday and forgot to check this. Feb 11, 2010 at 10:26
1

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.

1
  • 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 ;) Feb 9, 2010 at 14:43
0

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.

1
  • thanks, good to know indexing plays a role. I didn't really think of that, but makes perfect sense. Feb 9, 2010 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.