Someone
Someone

Reputation: 379

Optimization of using a database

Is it faster to get the whole object from the database and get needed attributes from the entity in Java app, or to get only needed attributes from the database?

Upvotes: 0

Views: 29

Answers (1)

Felice Pollano
Felice Pollano

Reputation: 33252

It depends, the rule is that you should minimize the number of roundtrip you do with the database. So you probably better load the entire object from the DB, if the entity is actually what you want. in other case, you should query just for a couple of properties on a lot of records, for example if you are drawing, say, a barchart. So we can't say a general rule but just minimizing roundtrips without having too heavy queries.

Upvotes: 1

Related Questions