ckc
ckc

Reputation: 373

NSFetchRequest vs NSAsynchronousFetchRequest performance

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?

Upvotes: 2

Views: 990

Answers (2)

pietrorea
pietrorea

Reputation: 898

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

Upvotes: 1

zeytin
zeytin

Reputation: 5643

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

Upvotes: 1

Related Questions