I am using the Struts 2 framework but this question is not just Struts 2 related.
I am trying to have some sort of pagination in my website. Let's say I have a list of records that I want to show on a page. The list has 150 records but I want to show 50 on each page so in this case there will be 3 pages. Of course, the list will be fetched from the DB.
The twist is that we have a restriction where if a query takes more than 7 seconds, it gets killed (don't ask). So if we get 150 records all at the same time our query is taking more than 7 seconds. So we decided to get 50 records every time. So in this case we will go to the DB 3 times (50 50 50). The first time we will fetch the total (150) so we know how many times should we go back to the DB.
Can some of you share your thoughts on how you would handle something like this? I know some of you might say that tweaking the stored procedure or query is the best bet but that will be a painful road to take as we have loads of SPs and queries.
I would appreciate any examples.