Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persisting a serialized object to a database

 
Reggie McDougal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could some one give me some advice here on the best way to appraoch this problem.

I have a database with a one to many relationship, the many in this case is lets say 1000 single rows of reference data.

Now my question is, how to achieve performance rather than searching all these rows is it better to store the data as a serialized object in this case an array, reducing the amount of rows in the database or should I just
store the data as a one to many?

Any ideas welcome.

Reg
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34681
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reggie,
The number of rows isn't a factor, it's the amount of data. I would go with the one to many relationship. I assume you have a table that has a foreign key along with the large objects. As long as there is an index on the foreign key, performance shouldn't be an issue.
 
Reggie McDougal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers, yeah its indexed and it flys I just needed to satisfy my curiosity.

But I have a better question, what abount when my app is initialised creating my objects in the heap (caching) so each time a punter makes a request it's not making a database call.

If any one has reading done this and whats the best approach from a design perspective.

Reg
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reg,

I just needed to satisfy my curiosity.

So try it both ways, and profile it. Then you'll know for sure which performs better. Usually, when we (software engineers) guess what performs better, we get it wrong. That's why we have profilers!

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic