In my iPhone application, i need to insert ~2000 records into Core Data before the user can use any features of the application. I am loading the records into CoreData from a local JSON file. This process is taking a long time(2.5+ minutes), but only needs to happen once(or every ~10 application opens to get updated data).
Is there a batch insert for Core Data? How can i speed up this insert process?
If i can't speed it up using Core Data, what are the other recommended options?
Check out the Efficiently Importing Data chapter from the Core Data Programming Guide.
I'm currently having the same problems as you, only I'm inserting 10000 objects and it takes around 30s, which is still slow for me. I'm doing a [managedObjectContext save] on every 1000 managed objects inserted into the context (in other words, my batch size is 1000). I've experimented with 30 different batch sizes (from 1 to 10000), and 1000 seems to be the optimum value in my case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With