[Dbix-class] count behaviour
Alex Povolotsky
tarkhil at over.ru
Tue Feb 26 11:34:03 GMT 2008
Ash Berlin wrote:
>
> 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.
Whooops... where is it documented?...
Alex.
More information about the DBIx-Class
mailing list