Slightly [OT]...
my @names = $db->query('SELECT name FROM people WHERE id > 5')->flat;
I thought that looked nice so I had a look at it. But when compared to the 'normal' DBI way it turns out there is really not much of an advantage. The line is a little shorter (++) but you get a dependency (--) and lose quite a bit of speed (--).
perl -MData::Dumper -MDBI -MDBIx::Simple -e ' my $db1 = DBI->connect; # (uses defaults to connect) my $db2 = DBIx::Simple->connect; use Benchmark qw( cmpthese ) ; my $COUNT = -20; print "-- COUNT [$COUNT]\n"; cmpthese( $COUNT, { selectrow_arrayref => sub { my @arr = @{ $db1->selectrow_arrayref( + "select i from generate_series(1,10) as f(i) where i > 5" ) }; }, dbix_query_flat => sub { my @arr = $db2->query( "select i from +generate_series(1,10) as f(i) where i > 5")->flat; }, }); ' -- COUNT [-20] Rate dbix_query_flat selectrow_arrayref dbix_query_flat 5608/s -- -23% selectrow_arrayref 7293/s 30% --
As always when I look closer at ORMy things (mainly because many people seem to be fond of ORMs), I don't think it's worth it.
In reply to [OT] Re^2: Populating an array via a DBI call - simplified
by erix
in thread Populating an array via a DBI call - simplified
by edimusrex
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |