I am using DBIx::Class::ResultSet to query for items and paginate my data. This is the query I use:
my $clients = $c->model('DB::User')->search(
{ active_yn => 'y', client_yn => 'y' },
{
columns => [qw/id first_name last_name username email/],
order_by => ['last_name'],
page => ($c->req->param('page') || 1),
rows => 20,
}
);
Once, I get the resultset, I loop through the results in Template::Toolkit like so:
[% WHILE (client = clients.next) %]
<tr>
<td>[% client.first_name %] [% client.last_name %]</td>
</tr>
[% END %]
My question is, does each time I call next
issue a new query? It is unclear to me because the all method says it returns all elements in the set, so does the first query not do that? I'd like to be as efficient as possible. Thanks!