Reputation: 1596
I was wondering, and never found any documentation to it, as to, first of all, what is an efficient way of fetching CD objects. In my app I have to store thousands of objects in my NSMOC and need to fetch them as fast as possible. Ois usi g NSPredicate the best way to fetch the entities that fit what I want the best way? Secondly, if I want to keep an "archive" type of thing where I store thousands of objects not used often, but I need to have them, is it possible to have two NSMOCs, and if so, will it speed up the process of fetching entities?
Thanks
Upvotes: 0
Views: 423
Reputation: 2664
If you want to fetch CoreData objects efficiently, you have to consider a few approaches:
NSFetchRequest
has a property called propertiesToFetch
which you can use to fetch only the properties you needrelationshipKeyPathsForPrefetching
property of NSFetchRequest
NSFetchRequest
object so that you fetch only the data you needYou can't say that NSPredicate
is the best way to fetch CoreData objects because you use NSFetchRequest
for this task, but it is definitely is a good idea to use NSPredicate
as well.
I don't think that having a separate MOC used as an "archive" is going to help your performance. You should probably read Apple documentation on CoreData performance
Upvotes: 1