wood burning stoves 2.0*
The moose likes JDBC and the fly likes Persisting a serialized object to a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Persisting a serialized object to a database" Watch "Persisting a serialized object to a database" New topic
Author

Persisting a serialized object to a database

Reggie McDougal
Ranch Hand

Joined: Sep 27, 2004
Posts: 69
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


You can never drink too much
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Reggie McDougal
Ranch Hand

Joined: Sep 27, 2004
Posts: 69
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

Joined: Oct 11, 2000
Posts: 1121

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Persisting a serialized object to a database
 
Similar Threads
Insert multiple rows in database
How to store an XML file as a string in database and retrieve in Java code
getConnection throwing NotSerializableException
XML vs. ???
display model object in jsp