Optimize a slow NSFetchedResultsController screen
WHAT IT TESTS: Core Data fetch tuning. OUTLINE: set fetchBatchSize so rows load in pages, use relationshipKeyPathsForPrefetching to avoid per-row faulting round trips, and add indexes matching sort and predicate to make queries fast.
WHAT IT TESTS: whether you can diagnose and tune Core Data fetch performance. ANSWER OUTLINE: fetchBatchSize loads objects in pages instead of all at once, keeping memory low and fetches incremental as the user scrolls; relationshipKeyPathsForPrefetching batch-loads related objects so accessing a relationship per row does not trigger N+1 faulting fetches; adding indexes, including compound indexes, on the columns used in the predicate and sort descriptors lets SQLite resolve queries quickly.
Read the original → interview
- #ios
- #core-data
- #performance
- #nsfetchedresultscontroller
- #faulting
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.