NSFetchRequest vs NSAsynchronousFetchRequest performance

Viewed 468

I am creating an iOS app that consists of a map. The data are stored using Core Data. When the app launches, which is the fastest way to fetch these data? NSFetchRequest or NSAsynchronousFetchRequest?

2 Answers

If UI fetch makes some delay or performance problem then you should use NSAsynchronousFetchRequest. I think you will probably fetch some annotations so you need to use NSAsynchronousFetchRequest

There is a nice answer here related to your question : https://stackoverflow.com/a/52973257/14531220

NSFetchRequest vs. NSAsynchronousFetchRequest is more about synchronous vs asynchronous, not really about speed. So if you're fetching in the UI context, it's about blocking the UI vs not while you wait for results to come back.

Depending on the # of records you're querying, there are other factors that could affect speed more significantly:

  • fetchBatchSize
  • fetchLimit/fetchOffset
  • Faulting
  • Optimizing your fetch predicate and sort descriptor
Related