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 8130039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:33:27+00:00 2026-06-06T08:33:27+00:00

I’m working with a very small sample project that can be downloaded from here

  • 0

I’m working with a very small sample project that can be downloaded from here. What I’m trying to do is debug why fetching is taking so long in my own project, but I’ve used this project as a sort of benchmark. I’ve enabled -com.apple.CoreData.SQLDebug 1in my scheme so I can see what commands are being sent to the SQLite store with my fetches.

First, in the AppDelegate, I just wrap the first part (where the bank is being created) in a for loop to create 1000 objects. Them comment out the fetch request from the AppDelegate.

Then, in the FBCFMasterViewController, there is a fetch request there. Upon running the app after saving the 1000 items, and fetching them to an NSFetchedResultsController, you’ll see thousands of output lines similar to these:

2012-06-23 09:16:30.374 FailedBankCD[90166:fb03] CoreData: annotation: sql connection fetch time: 0.0004s
2012-06-23 09:16:30.375 FailedBankCD[90166:fb03] CoreData: annotation: total fetch execution time: 0.0009s for 1 rows.
2012-06-23 09:16:30.375 FailedBankCD[90166:fb03] CoreData: annotation: fault fulfilled from database for : 0xc3e9060 <x-coredata://60E5B64A-83AB-4E6A-BEAD-5FFF50DB7F66/FailedBankDetails/p823>
2012-06-23 09:16:30.376 FailedBankCD[90166:fb03] CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZCLOSEDATE, t0.ZUPDATEDATE, t0.ZZIP, t0.ZINFO FROM ZFAILEDBANKDETAILS t0 WHERE  t0.Z_PK = ?

What I’m guessing that’s from is that the sortDescriptor is initialized with key details.closeDate, which is a relationship, so as it sorts by that property, it has to fetch fault each object in, causing thousands of lines of output to appear.

So I changed the sortDescriptor to sort on the property city instead, and this time when I run, I get the following output:

2012-06-23 08:53:04.924 FailedBankCD[89564:fb03] CoreData: sql: SELECT 0, t0.Z_PK FROM ZFAILEDBANKINFO t0 ORDER BY t0.ZCITY DESC
2012-06-23 08:53:04.929 FailedBankCD[89564:fb03] CoreData: annotation: sql connection fetch time: 0.0049s
2012-06-23 08:53:04.930 FailedBankCD[89564:fb03] CoreData: annotation: total fetch execution time: 0.0059s for 1009 rows.
2012-06-23 08:53:04.936 FailedBankCD[89564:fb03] CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZCITY, t0.ZNAME, t0.ZSTATE, t0.ZDETAILS FROM ZFAILEDBANKINFO t0 WHERE  t0.Z_PK IN  (?,?,?,?,?,?,?,?,?,?)  ORDER BY t0.ZCITY DESC LIMIT 10
2012-06-23 08:53:04.938 FailedBankCD[89564:fb03] CoreData: annotation: sql connection fetch time: 0.0013s
2012-06-23 08:53:04.939 FailedBankCD[89564:fb03] CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZCLOSEDATE, t0.ZUPDATEDATE, t0.ZZIP, t0.ZINFO FROM ZFAILEDBANKDETAILS t0 WHERE  t0.ZINFO IN  (?,?,?,?,?,?,?,?,?,?)  
2012-06-23 08:53:04.971 FailedBankCD[89564:fb03] CoreData: annotation: sql connection fetch time: 0.0318s
2012-06-23 08:53:04.972 FailedBankCD[89564:fb03] CoreData: annotation: total fetch execution time: 0.0326s for 10 rows.
2012-06-23 08:53:04.973 FailedBankCD[89564:fb03] CoreData: annotation: Prefetching with key 'details'.  Got 10 rows.
2012-06-23 08:53:04.974 FailedBankCD[89564:fb03] CoreData: annotation: total fetch execution time: 0.0372s for 10 rows.

I don’t get repeating thousands of lines of output anymore, and this appears to be the expected output. However, if I run again, without even modifying anything, I again get thousands of lines of output similar to the following:

2012-06-23 09:19:31.263 FailedBankCD[90216:fb03] CoreData: annotation: sql connection fetch time: 0.0006s
2012-06-23 09:19:31.264 FailedBankCD[90216:fb03] CoreData: annotation: total fetch execution time: 0.0010s for 20 rows.
2012-06-23 09:19:31.264 FailedBankCD[90216:fb03] CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZCITY, t0.ZNAME, t0.ZSTATE, t0.ZDETAILS FROM ZFAILEDBANKINFO t0 WHERE  t0.Z_PK IN  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  ORDER BY t0.ZCITY DESC LIMIT 20

This is odd behavior, no? Can anyone quickly replicate this and explain what’s going on, and why I’m getting thousands of lines of output?

  • 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-06-06T08:33:30+00:00Added an answer on June 6, 2026 at 8:33 am

    close_date and city aren’t indexed, that’s explain the thousands of queries, and probably low performance. For the difference between runs, I would bet on the cache you are using :

    NSFetchedResultsController *theFetchedResultsController =
    [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                        managedObjectContext:managedObjectContext sectionNameKeyPath:nil
                                                   cacheName:@"Root"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.