Originally posted by Dennis Lee:
I have to use Java to retrieve one million records in DB2 and write the records into a txt file. I think the ResultSet is unable to hold so many records in memory. We also need to get the better performance. How could I do? Hope to get your help. Thanks a lot.
Not a problem. Your resultset doesn't really hold the million records in memory ( unless you use a scrollable ResultSet == BAD ). I punch through a million records the same way I punch through 10:
The actual number of records held in memory at one time is equal to the FetchSize of the Statement/ResultSet. For processing a large number of records, you may want to increase the fetch size ( reduces the number of DB calls ) until you find that it's not increasing the application speed anymore.
Joe, not sure what this had to do with paging?
Originally posted by Joe Ess:
... And I did not know scrollable ResultSet loads all the results from a query. . .
scrollable results aren't all loaded into memory at first, but as you scroll forwards, the previously fetched results are stored in memory ( to allow you to scroll back ).
When I think of paging resultsets I usually think of web apps displaying parts of large results on a page with a next and back button. I can see what you intended in your post though.