perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Sabino Mullane <>
Subject Re: Database transaction across multiple web requests
Date Fri, 31 Mar 2006 14:22:52 GMT
Hash: SHA1

> Granted, I use a few MySQL features for this; I'm not sure if LIMIT
> exists in postgresql, and I'm fairly sure that the SQL_CALC_FOUND_ROWS
> directive (which will return the total rows in a select statement
> regardless of the LIMIT directives) doesn't...

Postgres has LIMIT and OFFSET. To determine the number of rows returned,
you can simply look at the return value of execute, or you can call

my $numrows = $sth->execute(1,2,42);

my $numrows2 = $sth->rows;

> (b) Repeat the query (making sure there is a sort criterium) at each
>     page request, starting at a variable offset and limiting the
>     result set

Generally, give solution (b) a try, by using LIMIT and OFFSET. It's a pretty
standard way of doing things. As mentioned, this will not work so well if the
table is changing between page views. If that is the case, and you truly want
a static view of the table from when they ran the first request, you'll
probably have to go to a lot more trouble, probably by creating copies of
the table if updates or deletes are being run, or storing the primary keys
if it is all inserts.

- --
Greg Sabino Mullane
PGP Key: 0x14964AC8 200603310921


View raw message