Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC vs Serialization

 
sridhar ponnusamy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi greeting,

For creating google suggestion kind of functionality ( on key press retrive a list of results) :
1) query the SQL table and fetching the records(using JDBC) every time based on key press.
2) fetch the records made to objects , put in a list and serialized already. on key press deserialize that list, manipulate the list(check for startswith()) and showing the results.

which approach is best

thanks in advance
Sridhar
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand your question. Why would you want to user serialization here?

Just get the results into a JDBC result set, and load them into memory. Are there too many for memory?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Querying the DB everytime is in fact faster and less memory hogging.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Querying the database on ever character change does sound like it might need some sort of caching mechanism, especially if you need some sort of expiry mechanism and more control over what is cached. Of course, as with any potential performance problem try it first, see if you actually have a problem. Serialization is not likely to be a good choice, because its limited and the extra persistance step is probably going to be slower than going to the DB every time. I'd also suspect this may need to be asynchronous; it's likely to drive users up the wall if they have to wait for the applciation to respond before entering another character.

Have a google for "java caches" there are a whole bunch of them out there that might suit your needs.
 
sridhar ponnusamy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much for all replies. Now i got an idea.....
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:Querying the DB everytime is in fact faster and less memory hogging.


True iff your searching mechanism is optimized.

For systems that don't have a search tool and allow queries directly against the database using things like wildcard values, searches could be incredibly slow. Granted, you wouldn't want to cache/store every wild card either.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic