Ok. This is the exact same question as here: Why is NSFetchedResultsController loading all rows when setting a fetch batch size?
But the solution for his doesn\'t solve
After reading the docs on the NSFetchedResultsController initializer, I think the problem is that you have a sort in the fetch request (created) that doesn't naturally sort the same as the section key path (sectionIdentifier). The specific sentence in the docs I'm looking at says:
If this key path is not the same as that specified by the first sort descriptor in fetchRequest, they must generate the same relative orderings
I recommend modifying your fetch request to sort on sectionIdentifier first, then created. I think that'll fix your issue.
NSSortDescriptor* updatedSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"created" ascending:NO];
NSSortDescriptor* sectionSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"sectionIdentifier" ascending:NO];
// It's critical the sectionSortDescriptor is first
[fetchRequest setSortDescriptors:@[sectionSortDescriptor, updatedSortDescriptor]];
Note that if either the created
or sectionIdentifier
properties are actually methods on your entity class, that will definitely force Core Data to load all your data before it can sort/section, because it needs to execute that method on each entity first.