NSFetchedResultsController initially takes too long to set up sections

Originator:enno.welbers
Number:rdar://11776243 Date Originated:29-Jun-2012 11:41 AM
Status:Open Resolved:
Product:iPhone SDK Product Version:5.0
Classification:Performance Reproducible:Always
 
Summary:
When setting up an NSFetchedResultsController to feed an UITableView with Sections and Section Index Titles for the first time, performFetch: takes a long time.
After Debugging for a while I noticed that there are two SQL Statements executed: one for the objects and another to fetch the section titles. Both Queries together take up to a few seconds (3GS, 1800 entries to be fetched).
As using another thread for performFetch: is not allowed by the documentation the UI will hang while the fetch is running.
That situation is not very pleasant for us developers, especially if a workaround is known and not documented.

Steps to Reproduce:
Build a Core Data dataset with roughly 3200 entries, where 1600 are to be fetched into 26 sections.
Set up a fetched results controller and call performFetch either:
1. without a cache name
2. for the first time with a cache

Expected Results:
A fast fetch which doesn't stutter the UI and doesn't leave the user in a unresponsive UI while fetching.

Actual Results:
The UI is blocked and the User has no feedback on what's happening.

Regression:

Notes:
This Text has been updated to remove information optained under NDA

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!