保存ManagedObjectContext的性能是否取决于所包含(不变)的对象的数量? [英] Does the performance of saving a ManagedObjectContext depend on the number of contained (unchanged) objects?

查看:60
本文介绍了保存ManagedObjectContext的性能是否取决于所包含(不变)的对象的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个常见的CoreData / SQLite问题

A general CoreData/SQLite question

保存 NSManagedObjectContext 时,这两种情况之间是否存在显着差异?使用SQLite存储:

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


  • 中添加/更改/删除一个对象后NSManagedObjectContext 包含 10 ,否则保持不变 NSManagedObjects

  • 添加/更改/删除后 NSManagedObjectContext 中的一个对象,其中包含 10'000 ,否则保持不变的 NSManagedObjects

  • 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

推荐答案

根据我对Enterprise Objects(Core Data的演变)的经验总结会说您的两种情况在没有索引的情况下将同样快,而在没有索引的情况下则稍慢。

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.

使用和存储SQL,无论图中有多少其他对象,添加一个对象的成本在很大程度上是固定的。索引确实会导致缩放效果,因为索引依赖于其他现有对象。但是,在大多数情况下,这并不重要。

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.

图内关系越复杂,则图的总大小会影响更多的保存。显然,如果您的图形只有十个对象,则没有关系可以包含十个以上的对象。如果您有一个拥有10,000的关系,则这些关系可能会更大,并且处理时间会更长。

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.

总而言之,带有SQL存储的Core Data似乎基本上不受图形大小的影响。

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

这篇关于保存ManagedObjectContext的性能是否取决于所包含(不变)的对象的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆