Strategy For Pagination?

Hi all,

I have a situation where I have to display results in the form of
page. To go about implementing I though of two things.

  1. I keep the query as per the selection made by user in session and
    limit the result every time user asks for a different page.This means
    every time hitting the Db.

2)I get the complete result in a session variable eg: array of model
instances and then use index of arrays to paginate the result.This
will involve lot of memory usage.

I’ll appreciate if someone guides me how to go about this.Displaying
result in pages is not an issue but the the way to achieve it has put
me on the back foot.

Regards
Gaurav V Bagga

Gaurav,

I may be misunderstanding you, but here is my take on it.

In nearly all typical pagination scenarios, #1 will be the way to go.

Trying to manually do it in memory is probably going explode your
application server as the volume of records grows along with the number
of users.

From my experience you have to ask yourself how much is enough before
determining a strategy for pagination.

If your user needs to page through a few hundred records, in batches of
10-50, then you should not have any issue using either the built in
paginator, or better yet the most excellent paginator built by Bruce
Williams (http://codefluency.com/projects).

From a useability standpoint, I still live by the words of a developer
who shared the following advice - if you expect your users to page
through thousands or tens of thousands of records, you don’t know your
users or use your own software.

You may want to consider other ways for users to locate what they are
looking for. Tags, dates, categories, search capabilties all allow you
to change the presentation of the data and allow users to find the
desired data more quickly than paging through page after page of
records.

Anyway, hope this helps.


Lon