Search code examples
iosswiftcore-datansfetchrequest

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?


Solution

  • 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