archon has asked for the wisdom of the Perl Monks concerning the following question:

I'm using HTML::Pager to divide up the output of a database request. Unfortunately, HTML::Pager uses the total number of rows of the request. If I use the offset and limit parameters in my Postgres query, I get the win of only grabbing the rows that I need. However, I lose because I don't know how many total rows there would be without a separate COUNT(*) query.

Any suggestions on the best way to get the total number of rows and the rows I need?

Replies are listed 'Best First'.
Re: HTML::Pager - how many rows?
by PodMaster (Abbot) on Jan 15, 2004 at 07:07 UTC
    Any suggestions on the best way to get the total number of rows and the rows I need?
    • Do the separate count query (i see no problem there).
    • Store the number of total rows on server side (as session data or whatever).
    • Encode it in the URL (what's the worst that could happen?)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.