Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2021-06-22 11:31 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (104 votes). Check out past polls.