Skip to content
Advertisement

connect to the database twice faster or connect once and store it locally?

I have a question in logic, to be honest I can’t categorize it.
My question is
If I have a table in database with 2 columns let’s say table called articles with article title and article content. and I develop mobile app which displays all the title in a list then when the user clicked on the title the will move to a new page “activity” and display its content.
I have 2 ways to develop that.

1- connect to the database once, select all the titles and all the content and store it locally and just display the content when its title is clicked

2- connect to the database twice. once to select all the titles, another one to select its content when clicked without storing anything locally

Please notice it is a mobile app so it doesn’t have a huge space to store locally.

My main question. which one of this method will be faster and efficient?

Advertisement

Answer

Option 2 seems better, because :

  • you mentioned that you don’t have a lot of local space available

  • only the content that the user needs will be retrieved, which, depending on the total size of the content, could save a lot of space AND time

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement