I'd additinally restrict the columns returned to the pk columns to save bytes going over the wire and using HRI to not instantiate a result object.
Looks like a nice addition to DBIC::Helpers! On 2015-02-12 08:22, QE :: Felix Ostmann wrote: We are using this function in our ResultSet.pm: sub exists { my ($self, $query) = @_; return $self->search($query, { rows => 1, select => [\1] })->single; } Have a nice day Felix 2015-02-12 1:05 GMT+01:00 Charlie Garrison <garri...@zeta.org.au<mailto:garri...@zeta.org.au>>: Good morning, On 11/2/15 at 10:58 PM +0100, Ekki Plicht (DF4OR) <e...@plicht.de<mailto:e...@plicht.de>> wrote:
I am thinking of setting up a special resultset which contains only the key as a returned value by SELECT, but I am wondering if there is a faster method.
Put a method in your ResultSet class, eg: sub key_exists { my ($self, $key) = @_; my $row = $self->find( $key ); return $row ? 1 : 0; } Elsewhere: my $got_row = $schema->resultset('RSClass')->key_exists($key); Charlie -- Charlie Garrison <garri...@zeta.org.au<mailto:garri...@zeta.org.au>> github.com/cngarrison<http://github.com/cngarrison> metacpan.org/author/CNG<http://metacpan.org/author/CNG> O< ascii ribbon campaign - stop html mail http://www.ietf.org/rfc/rfc1855.txt _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class<http://irc.perl.org#dbix-class> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"* T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien Handelsgericht Wien, FN 79340b *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"* Notice: This e-mail contains information that is confidential and may be privileged. If you are not the intended recipient, please notify the sender and then delete this e-mail immediately. *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk