开发者

Core Data - Large Datasets and Very Long Load Times

开发者 https://www.devze.com 2022-12-13 01:28 出处:网络
I\'ve got about 5000-7000 objects in my core data store that I want to display in a table view. I\'m using a fetched results controller and I haven\'t got any predicates on the fetch. Just a sort on a

I've got about 5000-7000 objects in my core data store that I want to display in a table view. I'm using a fetched results controller and I haven't got any predicates on the fetch. Just a sort on an integer field. The object consists of a few ints and a few strings that hold about 10 to 50开发者_JAVA百科 chars in. My problem is that it's taking a good 10 seconds to load the view. Is this normal?

I believe that the FRC handles large datasets and handle's batches and such things to allow large datasets. Are there any common pitfalls or something like that because I'm really stumped. I've stripped my app down to a single table view, yet it still takes around 10 seconds to load. And I'm leaving the table view as the default style and just displaying a string in the cell.

Any advice would be greatly appreciated!


Did you check the index checkbox for the integer you are sorting on in your Core Data model?


On your fetch request, have you used -setFetchBatchSize: to minimize the number of items fetched at once (generally, the number of items onscreen, plus a few for a buffer)? Without that, you won't see as much of a performance benefit from using an NSFetchedResultsController for your table view.

You could also limit the properties being fetched by using -setPropertiesToFetch: on your fetch request. It might be best to limit your fetch to only those properties of your objects that will influence their display in the table view. The remainder can be lazy-loaded later when you need them.

0

精彩评论

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

关注公众号