Perrin Harkins wrote:
I typically use a combination, retrieving all of the IDs in order in
one shot and saving that in a cache, and then grabbing the details of
the 10 records needed for the current page as I go. This is described
somewhat here:
http://perl.apache.org/docs/tutorials/apps/scale_etoys/etoys.html#Search_servers
I'm with Perrin here, grab PKs for the entire resultset, your DB is
going to do most of that work anyway if you're doing a count(*) to get
the size of the resultset.
Stick that list in a cache somewhere using your favourite caching
module. If you have a bunch of popular queries, chances are they'll
almost always be in the cache anyway.
You can then use Data::Page or similar to do your pagination. Having got
your paginated list expand out the PKs into rows, or turn them into
objects using your favourite ORM. Feed it all into your favourite
templating system.
Whole lot - couple of dozen lines of code?
Carl