开发者

Saving records to coreData takes too long, how can i insert them quicker?

I am introducing in my coreData DB some objects.

The problem is that it is quite slow(8-10 seconds) although i am introducing only 50 records.

I am introducing these records individually, could the insertion be faster if I introduce them all at once? If yes, how can I do so(insert an array to coreData) ?;

Any other coreData speed-insertion tips woul开发者_开发知识库d be welcome :)


I would use Instruments and run the Profiler instrument over your insert operation and see what is actually slowing it down. My guess would be that you're performing some sort of deserialization or parsing when inserting the object, or one of the other common slowdowns of data operations. Make sure you've got the problem identified before optimizing.


Several seconds for only 50 entities saved is quite strange. Run Instruments on it and see where the bottle neck is.

If possible break out your Core Data code into a test that can be run on a Mac OS X target, since Instrumemts has a specific, and much better, template for profile Core Data for Mac OS X only (Make sure to file a bug request at http://bugreport.apple.com to bring the Core Data template to iOS apps as well).

If it is a bottle neck that can not be removed, at least make sure to do this save operation on a background thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜