[Dbix-class] count behaviour
Ash Berlin
ash_cpan at firemirror.com
Tue Feb 26 11:31:20 GMT 2008
On 26 Feb 2008, at 11:23, Alex Povolotsky wrote:
> Hello!
>
> I'm using (with Catalyst and TT) some simple code to count related
> data
>
> [% FOREACH loc IN llist -%]
> <li>[% loc.name %] : (<a href="[% Catalyst.uri_for("edit/$loc.lid")
> %]>Edit</a>)
> [% loc.contacts.count+0 %] contacts (more): [% loc.servers.count+0
> %] servers (more):
> here will be traffic
> [% END -%]
>
> Debugging SQL requests, I've found that both counts use "select *"
> instead of "select count(*)".
>
> Is it a bug or a feature? Maybe count should be better optimized?
>
> Alex.
>
TT calls everything i list context. So that count method is actually
TT's count vmethod.
you want [% loc.contacts_rs.count %] to get SELECT COUNT(*) executed.
Ash
More information about the DBIx-Class
mailing list