问题描述
如果我的作者
NSManagedObject
模型有 authorID
属性(由服务器确定),如果 NSPredicate
过滤器,则
而不是完整的 NSFetchRequest
authorID 作者
对象?假设我通过某个作者获取所有
Book
NSManagedObject
$ c>。 predicateWormFormat
If my Author
NSManagedObject
model has a authorID
attribute (determined by the server), will an NSFetchRequest
perform better if the NSPredicate
filters by authorID
rather than the complete Author
object? Let's say I'm fetching all Book
NSManagedObject
s by a certain author
. Which predicateFormat
is better?
[NSPredicate predicateWithFormat:@"author = %@", anAuthor]
或
[NSPredicate predicateWithFormat:@"author.authorID = %@", anAuthor.authorID]
什么是最好的方式来归档这个?我有使用 OCUnit
( SenTestingKit
)的核心数据测试。 iOS有类似吗?
What's the best way to profile this? I have Core Data testing working with OCUnit
(SenTestingKit
). Does iOS have something like Ruby's Benchmark module?
推荐答案
可能值得使用 -com.apple.CoreData.SQLDebug 1
,详情请参阅。
然后,您可以看到Core Data是否在两种情况下都执行相同的SQL(假设您使用的是SQLite存储)。
You could then see if Core Data was executing the same SQL in both circumstances (assuming you're using a SQLite store).
这篇关于核心数据性能:NSPredicate比较对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!