Pagination

Hi friends

Im developing a web application where im fetching data from database. For showing the records i have to implement pagination. now the data could be 1000 - 2000 records also... so keeping it in session does not sound good to me. and i also dont want to hit the database again and again. so i came to conclusion that i'll fetch and cache the records in chunks..that too on request basis.. ie first hundered records will be fetched and cached and then if user tries to access record 101th onwards .. then only i'll fetch the next chunk. now can any body help me out we a better idea or could suggest some in this one...

thanks in advance.......

[673 byte] By [Neo2001a] at [2007-11-26 18:17:55]
# 1

Unless the records are huge, 1 or 2 K isn't going to be much memory. However, the idea of bringing back only what the user can view at first isn't a bad idea. If you can start showing data before everything is retrieved and processed, you will create a much better user experience.

The main problem is that you have to figure out how to retrieve more records as needed. I would avoid keeping a database cursor open for a long time (where user think time is a long time.) You could consider a server-side cache for the data or other solutions like Hibernate, EJB3, etc.

But I would first really think about your data. Is it really that big that you need to avoid holding the whole response? It's not that this is the best solution but that it's the easiest to implement.

dubwaia at 2007-7-9 5:51:32 > top of Java-index,Other Topics,Algorithms...
# 2

> But I would first really think about your data. Is

> it really that big that you need to avoid holding the

> whole response? It's not that this is the best

> solution but that it's the easiest to implement.

I would say that holding the entire response is quite often the best solution. Why? Because if the response is too large to fit in memory, it's almost certain it is too large to be presented to the user. Paged or not, users generally don't want to be shown multiple megabytes of data.

DrClapa at 2007-7-9 5:51:32 > top of Java-index,Other Topics,Algorithms...
# 3

> I would say that holding the entire response is quite

> often the best solution. Why? Because if the response

> is too large to fit in memory, it's almost certain it

> is too large to be presented to the user. Paged or

> not, users generally don't want to be shown multiple

> megabytes of data.

As a general rule of thumb I agree completely. But without knowing the actual requirements, it's hard to say for sure.

dubwaia at 2007-7-9 5:51:32 > top of Java-index,Other Topics,Algorithms...
# 4
> users generally don't want to be shown multiple megabytes of dataUnless the data forms a picture (or sequence of pictures) of Palema Anderson.
rkippena at 2007-7-9 5:51:32 > top of Java-index,Other Topics,Algorithms...