I don't know what your application does and I didn't react on this before,
but honestly, I can't imagine someone will ever spend time reading (and even
waiting for) a page showing 50,000 records... The page will be MB's large,
and it would take ages to render. From a usability point of view, a
scrollable list is preferred.
Depending on the RDBMS, you can make queries to select the "n items at
position y" (like the 10 records from 50 to 60). I'm not an SQL specialist,
but I believe these are extensions to plain SQL, but I think it's a fair
trade-off to break database portability for usability.
I was reading that PDF incidentally (
http://www.nyoug.org/javasets.pdf)
while looking at how to implement efficiently a JDBC query with a large
ResultSet. Interestingly, it says that the ScrollableResultSet will cache
the data as it is being read (slide 23). It goes about Oracle, but I'd
suppose all implementations do it that way. This means that as your loop is
looping
you are caching more and more data. Not sure, but it could be
that you end up caching the 50,000 rows in your servlet...