Prakash Donga
Prakash Donga

Reputation: 558

Core Data NSFetchedResultsController

How to reduce fetch request time in core data?

I am fetching 10000 data from .sqlite file using core data NSFetchedResultsController it is taking too much time to load.

Upvotes: 1

Views: 308

Answers (2)

TechZen
TechZen

Reputation: 64428

See: Core Data Performance in the Core Data Programming Guide

Usually, you want to set a fetch limit and fetch as faults. That way you only end up with a small array of lightweight proxy objects. You should also make sure to use the NSFetchResultsController's cache.

However, you might want to rethink your UI design. I single table with 10,000 rows is insane especially on a mobile device. Even using an index table, your a asking your users to slog through hundreds of rows. You should think about breaking the data up into some kind of logical hierarchy so that you can display in an hierarchy of tableviews. In principle, you could display 10,000 objects in 4 tables with only 10 choices each. That would be easier for the user to navigate and the corresponding fetches for each table would be light and fast as well.

Upvotes: 6

Dan
Dan

Reputation: 1729

You could try just fetching the object id instead of the entire object. It's usually faster.

Upvotes: 0

Related Questions