Tomas Zerolo wrote:
Howdy,

Howdy to you :)

this is not strictly a modperl question, but I'm sure some of you are
downright experts on this.

We have a modperl2 applicattion with a database backend (PostgreSQL,
DBI). For session management we use Apache::Session.

Now the need has arisen to serve requests yielding many records as
answers -- so the user wants to page through them, a bunch at a time,
search-engine style.


use Data::Paginate;

As far as the queries go you have basically two choices:

a) If the connection is persistent and you can pass a hash around then do the query once, store the data in the hash keyed on the session.

The problem here is your memory (and possible security) issues would seem to overwhelm the "one query" only benefits. (plus your initial query page would have one huge result set to manage so itd take alonger)

b) Is to do it like the Example in Data::Paginate's POD:

Initially you do one simple count query. That is used to build your pagination object and then each request does a LIMITed SELECT on the current pages's records.

Its quite fast and efficient and easy to code and maintain, we use it all the time (essencially pasting in the example code). *And* if your DB connection is persistent its even zippier :)

HTH

Reply via email to