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

  • Home
  • SEARCH
  • 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 7367981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:36:24+00:00 2026-05-29T03:36:24+00:00

I struggled with the title for this question, it is hard to summarize into

  • 0

I struggled with the title for this question, it is hard to summarize into a one-liner. I will try to keep it as straight to the point as possible.

I am developing an app where I am displaying a custom UIView (a chart) and a UITableView with data. Each row in the tableview represent a point in time with a value, lets say its Account Balance.

The tableview only displays 3 rows at a time and the middle row acts as the “active” row. The active row is used to decide what is displayed in the chart. Any AccountBalance with a timestamp either < 12hours before or after is displayed in the chart. Making the chart display a 24 hour window of data.

This is where I am struggling to decide what would be the best design approach in terms of optimizing and reduce lag when scrolling in the tableview. Basicly I have logic to determine which row is in the middle by using UIScrollView delegate methods. This works fine.

To decide what data to display I perform a NSFetchRequest with a predicate everytime the middle row changes (a new request everytime the row changes). When this is complete I call setNeedsDisplay on the chart-view and it is redrawn.

While this works fine at a small dataset so far I have a gut feeling that I could somehow leverage Core Data’s performance and caching better to reduce lag even more. Any ideas and thoughts are much appriciated.

This might not be a common problem and not interest many people, but I figure a discussion about best practise here could apply to more situations than mine, and hence be of value to more people.

  • 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-29T03:36:25+00:00Added an answer on May 29, 2026 at 3:36 am

    What you probably want to use is batch fetching (NSFetchRequest allows you to set the batch offset and size). That’s exactly what the NSFetchedResultsController uses to make sure it only fetches a few objects at a time.

    You need to be aware that there’s a balance to be made: If you have a large batch size (e.g. 300 rows / objects), you force CoreData to create 300 objects at a time (as opposed to a smaller number). But if you set the batch size to something small (e.g. 3 rows / objects) you’ll pay a high price because you’ll end up pulling in batches very often (which is very expensive).

    You’ll have to test to see what batch size is good for you, but it’s typically something like twice the number of objects you’re displaying at once.

    The array that the NSFetchRequest returns when you turn on batch fetching (by setting a batch size) will do some magic behind your back and it’ll only fill in that array as you iterate through it. And it’ll only keep objects in memory for a few batches before and after what you’re currently using.

    It’s very easy to misuse batch fetching and make things slower. E.g. if you have an array that’s batch fetching and you have some (broken) logic that loops through all objects, you’ll end up pulling in all batches in the set one by one — defeating the purpose of batch fetching.

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

Sidebar

Related Questions

I struggled to write a more appropriate 'title' to this question - I will
Okay, this one is the reverse of the last question I struggled with... I
I struggled to come up with a good title for this question, so suggestions
This is a very lame question, but I have struggled with it far too
This is one i struggled with for ages so thought I'd document somewhere. (Apologies
First of all, my apologies for the title of this question, I don't have
I've struggled with this one for a long time. This query runs fairly fast
I struggled to sum this up in a title, so apologies if it is
Since I struggled a bit with this one and couldn't find a good online
We Really need some help on this one: We've Struggled with all the Apple

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.