[Dbix-class] paging question

James Marca jmarca at translab.its.uci.edu
Tue Feb 2 19:58:24 GMT 2010


On Tue, Feb 02, 2010 at 11:14:27AM -0800, James Marca wrote:
> Hi.  
> 
> First DBIx::Class is excellent and kudos all around.
> 
> I have recently needed to use the paging feature for the first time
> and I'm not sure of the best way to do this.
> 
> First a simple question:  How should one terminate the paging?  Is
> there some variable to check to find out how many pages of data are
> expected from a result set?  I couldn't find anything in the docs,
> but I probably missed it.

Clarifying my question... I am aware of the ability to call

my $data_page_object = $rs->pager();
my $total_count = $data_page_object->total_entries();

But that looks like it will hit the database once with a count(*)
select call, which in PostgreSQL is expensive.  What I am hoping for
is something along the lines of 

my $paged_rs = $rs->page($nextpage);
if (! $paged_rs || ! $paged_rs->no_more_data ){
  return;
  # undefined page result set means I've gone beyond the max pages
  # while calling $paged_rs->first would hit the db with that
  # expensive query
}

No, I have no idea how to get that result without asking for it
explicitly from the db, but just because I can't figure that out
doesn't mean it is impossible!

Regards,
James


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the DBIx-Class mailing list