Hi Satish,

It will not be possible to use my solution with displaytag... because, as you probably already know, displaytag needs the whole list to paginate and I want to get away from loading the entire resultset in memory.

I can most definetly post my solution to the problem once I've finalized everything.

The general idea is as follows:

1) You configure iBatis with two queries. One for counting and the other for the resultset 2) You use the count to paginate *empty* pages. Each page contains an index and an offset. These are calculated on the first view 3) Every time the user clicks next or back, the respective page's index & offset is retrieved and passed to the sqlMap for "queryForList". The resulting list is used to display the correct page.

This is MUCH better than queryForPaginatedList (and my original binarySearch method). For my tables with 40,000+ records, the method above is lightning fast... but with queryForPaginatedList (with associated overhead calculations) the performance crawled to a snail's pace.

Although displaytag is good... I found it really bad for large result sets OR for results set that you want to manipulate (ie: change the number of rows, hide/show columns, edit fields). The solution that I'm working on currently does all of those things except for editing of fields (which I'm working on right now).


Anyhow, take care.
Aladin





Rao, Satish wrote:
Hi Aladin,

I am trying to do something very similar. I am using a queryForList() to
return records and then using DisplayTag
(http://displaytag.sourceforge.net/) to create a pagination.

I wanted to look at your solution as to how you are passing in offset
and index and creating the jsp page (with page numbers, prev and next
link). Will it be possible for you to email me the code snippet? That
will be of great help.

Also how is the performance?

Thanks,
Satish


-----Original Message-----
From: Aladin [mailto:[EMAIL PROTECTED] Sent: Thursday, June 30, 2005 12:12 AM
To: [email protected]
Subject: Re: PaginatedList question


Thanks for the response Clinton.

Since the last post, I have implemented my system using the queryForList() and am managing my pages using an index & offset.

Take care.
Aladin



Clinton Begin wrote:

Hi Aladin,

PaginatedList is meant for simple systems that have the luxury of keeping a page of data around in memory. In a high performance system


that needs to scale, keeping even a page of records in memory is a bad


idea...regardless of PaginatedList.  Even 25 records per page could be


devastating in a system with 10,000 concurrent sessions (in fact

session
management in general could be an issue at that point). So you're much


better off just storing a) the current page and b) the page size --basically 2 that in total use up less memory than a single PaginatedList page...

PS: Doing a binary search is a) way slower and b) way more work than just doing count(1).

Cheers,
Clinton

On 6/28/05, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

<[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:

   Hi Clinton,

   I'm interested in knowing why you would discourage the use of the
   paginated list in a "high performance" system?

   In response to another post...

   In order to compute the number of pages (using the paginatedlist),

a

   simple binary search method can be applied once when the result is

first

   queried.  This binary search finds the last page in the set;
   reducing the
   set by half on every iteration (hence binary).  Of course, some

critical

   assumptions have to be made.  The end result is something very
   similar to
   google, where it tells you that your search yielded n pages with m
   records... but when you click on the last page, those numbers are
   re-adjusted.  I hope this makes sense to you...

   Nevertheless, I am more interested in why the use of the paginated
   list is
   discouraged.

   Thanks.
   Aladin

    > The documentation is mistaken. Previous() should not wrap for

the

    > paginated
    > list. Regardless, you shouldn't use that approach to calculate
   the number
    > of
    > pages, you should use a separate count(*) query and divide by
   page size.
    >
    > For high performance systems, you should not use paginated list

at

    > all....you should use queryForList with skip and count

parameters.

    >
    > Clinton
    >
    >
    > On 6/27/05, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
   <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
    >>
    >> Hello,
    >>
    >> I seem to be having some problem with the PaginatedList.
    >>
    >> When I'm on the first page and I do

paginatedList.getPreviousPage(),

    >> iBatis doesn't wrap to the last page... as specified in the
   javadoc. I
    >> need this wrapping functionality to compute the total number

of

   pages in
    >> the result set.
    >>
    >> Does anyone have any idea as to why this might be happening?
    >>
    >> I am using postgres with jdb3.
    >>
    >> Thanks.
    >> Aladin
    >>
    >





Reply via email to