Retrieving data from database. Retrieve only when needed or get everything?

Posted by RHaguiuda on Stack Overflow See other posts from Stack Overflow or by RHaguiuda
Published on 2010-05-24T20:12:13Z Indexed on 2010/05/24 20:21 UTC
Read the original article Hit count: 230

Filed under:

I have a simple application to store Contacts. This application uses a simple relational database to store Contact information, like Name, Address and other data fields.

While designing it, I question came to my mind:

When designing programs that uses databases, should I retrieve all database records and store them in objects in my program, so I have a very fast performance or I should always gather data only when required?

Of course, retrieving all data can only be done if it`s not too many, but do you use this approach when you make sure that the database will be small (< 300 records for example)?

I have designed once a similar application that fetches data only when needed, but that was slow (using a Access database).

Thanks for all help.

© Stack Overflow or respective owner

Related posts about database