I'm currently developing a mobile application in Objective C for iOS devices. While doing the application I reach the point where I have to retrieve data from a database and show it on a table (the name of a specific workout routine and his description).

The way I see it I can do this in two ways:

  1. I can select every workout from the database and the associated description, build a collection of objects, send it to the appropriate controller and show in a table all the names, when one is selected I can send the appropriate object to another controller (the one from the next view) and show the appropriate description (this way I just do one operation over the database and manage a lot of objects).
  2. The other way of doing this is just retrieving all the workouts names, when one is selected retrieve the associated description from the database and show it (this way I do two operations over the database but manage a lot of less data and objects in the application).

What I'm concerned about is performance. Is it better to do more operations over the database and manage less information and objects in the application or is it better to do less operations over the database and manage more information and objects? I know that every application is different and one answer can't be applied to everyone of them, but how should I think about it when developing one?

  • 1
    Is the database on the device, or on a server somewhere? Mar 20, 2014 at 0:48
  • I think this depends on how big your table is and how big the description column is. Mar 20, 2014 at 6:24
  • What makes you think retrieving data from a database would take a noticeable amount of time? Retrieving all the data into a collection will almost certainly cause an "out of memory" at some point. Mar 20, 2014 at 7:00
  • @DanPichelman in this particular case the database is on the device Mar 20, 2014 at 13:15

1 Answer 1


Since the database is on the device (per comments), I would focus my performance concerns on memory management over speed.

Talking to a local database is crazy fast unless you're doing something really unusual (e.g., sequencing DNA, cracking encryption, anything with millions or billions of loop iterations).

You might find the accepted answer to Planning for efficiency early vs Premature optimization helpful.

Long story short, it's not going to matter.

Take the approach that's easiest to maintain and debug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.