核心数据性能:NSPredicate比较对象 [英] Core Data Performance: NSPredicate comparing objects

查看:130
本文介绍了核心数据性能:NSPredicate比较对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的作者 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 NSManagedObjects by a certain author. Which predicateFormat is better?

[NSPredicate predicateWithFormat:@"author = %@", anAuthor]

[NSPredicate predicateWithFormat:@"author.authorID = %@", anAuthor.authorID]

什么是最好的方式来归档这个?我有使用 OCUnit SenTestingKit )的核心数据测试。 iOS有类似 Ruby的基准化模块吗?

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比较对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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