Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7441347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:59:46+00:00 2026-05-29T10:59:46+00:00

So, I am trying to fetch around 2000 objects from core-data and trying to

  • 0

So, I am trying to fetch around 2000 objects from core-data and trying to find out which would be the fastest way to fetch them.

Without NSPredicates:

When I add this block (below), the if statement takes 90% of the total time taken to execute, which is understandable, and so I comment it out.

Block {

    NSError *error;
    NSManagedObjectContext *context =  <#Get the context#>;

    // The IF block

/*   if (![context save:&error])
    {
        NSLog(@"error %@", error);
    }
*/
       // The block above takes 90% of the total time of fetch

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *theEntity = [NSEntityDescription 
                                  entityForName:@"EntityName" inManagedObjectContext:context];

    [fetchRequest setEntity:theEntity];

    NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];    

    }

With NSPredicates:

I set the predicate as

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"handle == %@",handle];

and perform the same fetch as shown in Block()

It can be seen that the overall time is the exact opposite -it’s around 90% faster if I use the IF BLOCK ~ 6 seconds.

Otherwise, if that block is commented, the fetching time is a LOT ~ 3 minutes. This happens only when set a predicate for the fetchRequest.

Can someone please explain ?

That is,

 /*
 Save + straight fetch = slow, due to saving. 
 Straight fetch - pretty fast. 
 Predicate fetch, slow. 
 Save + predicate fetch, much faster? 
 */
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:59:48+00:00Added an answer on May 29, 2026 at 10:59 am

    (Guesswork, hopefully educated) After a save the context can perform a predicated fetch directly against the database as it knows that there are no objects whose changes have not been written to the DB yet. Without the save, it has to fetch against the DB and also any extant objects who may have unsaved changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to get my head around using Lambda expressions to fetch data from my
I'm trying to fetch data from a div (based on his id), using PHP's
I'm trying to populate a table structure with around 5 fields of data from
I'm trying to fetch some HTML from various blogs and have noticed that different
I'm trying to fetch some settings from my membership provider in my asp.net application
i am trying to fetch anything that looks like a URL from a string
I'm trying to fetch the most popular tags from all videos in my database
I trying to fetch the time from the phone's clock but am not able
I'm trying to pull some html data from a mysql database to populate a
I am trying to retrieve around 200 billion rows from a remote SQL Server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.