Re: [Dbix-class] Fastest method to check for key existence?

2015-02-13 Thread QE :: Felix Ostmann
I often build a map and use this also for an exist()-check (not for bigdata) my %email_for = map { $@_ } $rs ->search( undef, { select => qw[ user_id email ], }, ) ->cursor ->all ; only important is t

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-13 Thread Ekki Plicht (DF4OR)
Ooookay... that's a lot of very helpful answers. Many thanks for all the suggestions, I guess I will go with the helper or with count(). Thanks, Ekki 2015-02-13 11:32 GMT+01:00 Will Crawford : > On 11 February 2015 at 21:58, Ekki Plicht (DF4OR) wrote: >> Hi, >> I need to check a list of values

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-13 Thread Will Crawford
On 11 February 2015 at 21:58, Ekki Plicht (DF4OR) wrote: > Hi, > I need to check a list of values if they exist in a database. The > value is a unique key of that table. A stupid 'find' works of course, > but returns the whole row data, where I only need a simple binary > yes/no information if a r

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-12 Thread David Cantrell
On Thu, Feb 12, 2015 at 12:25:55PM +, Lianna Eeftinck wrote: > Or just use ->count, which doesn't need to retrieve and instantiate the > objects. Something like this: SELECT COUNT(*) FROM foo WHERE bar IN ('ant', 'bat', cat', 'dog'); might tell you that two of them exist, but I got the im

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-12 Thread Lianna Eeftinck
Or just use ->count, which doesn't need to retrieve and instantiate the objects. On 12 February 2015 at 11:33, Dmitry L. wrote: > On 12 February 2015 at 14:27, Hartmaier Alexander > wrote: > > I'd additinally restrict the columns returned to the pk columns to save > > bytes going over the wire

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-12 Thread Dmitry L.
On 12 February 2015 at 14:27, Hartmaier Alexander wrote: > 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! > Looks like already there: DBIx::Class:

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-12 Thread Hartmaier Alexander
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 e

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-11 Thread QE :: Felix Ostmann
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 : > Good morning, > > On 11/2/15 at 10:58 PM +0100, Ekki Plich

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-11 Thread Charlie Garrison
Good morning, On 11/2/15 at 10:58 PM +0100, Ekki Plicht (DF4OR) 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

[Dbix-class] Fastest method to check for key existence?

2015-02-11 Thread Ekki Plicht (DF4OR)
Hi, I need to check a list of values if they exist in a database. The value is a unique key of that table. A stupid 'find' works of course, but returns the whole row data, where I only need a simple binary yes/no information if a row was found or not. I am thinking of setting up a special resultse