• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving big list from that database and memory

 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi:
How can I retrieve a big list from the database without consuming so much memory?
In my model, I use transfer objets to bring the data from the database to my application. Basically, I read every row from the ResultSet, then I encapsulate it into a corespondent object. But, what will happen if I have too many rows in the ResultSet? I will have to create too many objects, which will take too much memory.
Not: Also, I want to mentain a relationship to the acual record, for example: I want to retrieve all the the internet providers from the database, and display the name to the user, when the user click on the name, my DAO should retrieve the provider data and display it to the user. But if I have 1000 providers, I will have to create 1000 objects.
how can I solve this problem?
I am new to the database stuff, and any help is appreciated.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid there's no easy answer to this. You can try to tailor your SQL statement to return a smaller ResultSet. Barring this though, I'm afraid you're stuck. You could of course just read in primary key values and then read in the actual ones you need when you need them. That would incur more network traffic though. However, your memory footprint would be smaller.
I suppose you'll just have to weigh the options and your performance/memory needs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic