<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Or just use ->count, which doesn't need to retrieve and instantiate the objects.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 February 2015 at 11:33, Dmitry L. <span dir="ltr"><<a href="mailto:dim0xff@gmail.com" target="_blank">dim0xff@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 12 February 2015 at 14:27, Hartmaier Alexander<br>
<span class=""><<a href="mailto:alexander.hartmaier@t-systems.at">alexander.hartmaier@t-systems.at</a>> wrote:<br>
> I'd additinally restrict the columns returned to the pk columns to save<br>
> bytes going over the wire and using HRI to not instantiate a result object.<br>
><br>
> Looks like a nice addition to DBIC::Helpers!<br>
><br>
</span>Looks like already there: DBIx::Class::Helper::ResultSet::Shortcut::HasRows<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
><br>
> On 2015-02-12 08:22, QE :: Felix Ostmann wrote:<br>
><br>
> We are using this function in our ResultSet.pm:<br>
><br>
> sub exists {<br>
> my ($self, $query) = @_;<br>
><br>
> return $self->search($query, { rows => 1, select => [\1] })->single;<br>
> }<br>
><br>
><br>
> Have a nice day<br>
> Felix<br>
><br>
><br>
> 2015-02-12 1:05 GMT+01:00 Charlie Garrison <<a href="mailto:garrison@zeta.org.au">garrison@zeta.org.au</a>>:<br>
>><br>
>> Good morning,<br>
>><br>
>> On 11/2/15 at 10:58 PM +0100, Ekki Plicht (DF4OR) <<a href="mailto:ekki@plicht.de">ekki@plicht.de</a>> wrote:<br>
>><br>
>> >I am thinking of setting up a special resultset which contains only<br>
>> >the key as a returned value by SELECT, but I am wondering if there is<br>
>> >a faster method.<br>
>><br>
>> Put a method in your ResultSet class, eg:<br>
>><br>
>> sub key_exists {<br>
>> my ($self, $key) = @_;<br>
>> my $row = $self->find( $key );<br>
>> return $row ? 1 : 0;<br>
>> }<br>
>><br>
>><br>
>> Elsewhere:<br>
>><br>
>> my $got_row = $schema->resultset('RSClass')->key_exists($key);<br>
>><br>
>><br>
>> Charlie<br>
>><br>
>> --<br>
>> Charlie Garrison <<a href="mailto:garrison@zeta.org.au">garrison@zeta.org.au</a>><br>
>> <a href="http://github.com/cngarrison" target="_blank">github.com/cngarrison</a> <a href="http://metacpan.org/author/CNG" target="_blank">metacpan.org/author/CNG</a><br>
>><br>
>> O< ascii ribbon campaign - stop html mail<br>
>> <a href="http://www.ietf.org/rfc/rfc1855.txt" target="_blank">http://www.ietf.org/rfc/rfc1855.txt</a><br>
>><br>
>><br>
>> _______________________________________________<br>
>> List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
>> IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
>> SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
>> Searchable Archive:<br>
>> <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
> IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
> SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
> Searchable Archive:<br>
> <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
><br>
><br>
><br>
><br>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*<br>
> T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien<br>
> Handelsgericht Wien, FN 79340b<br>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*<br>
> Notice: This e-mail contains information that is confidential and may be<br>
> privileged.<br>
> If you are not the intended recipient, please notify the sender and then<br>
> delete this e-mail immediately.<br>
> *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*<br>
><br>
> _______________________________________________<br>
> List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
> IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
> SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
> Searchable Archive:<br>
> <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
//wbr, Dmitry L.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
</div></div></blockquote></div><br></div>