in reply to Re: DBI Hash of Column name values
in thread DBI Hash of Column name values

Still slower than bind:

{ my $t0 = [ gettimeofday ]; my $n = 0; my $rows = $dbh->selectall_arrayref ($sql, { Slice => {} }); foreach my $row (@$rows) { $n++; } printf STDERR "slice: %9.2f recs/sec\n", $n / tv_interval ($t0); } { my $t0 = [ gettimeofday ]; my ($n, %rec) = (0); my $sth = $dbh->prepare ($sql); $sth->execute; $sth->bind_columns (\@rec{@{$sth->{NAME_lc}}}); while ($sth->fetch) { $n++; } printf STDERR "bind: %9.2f recs/sec\n", $n / tv_interval ($t0); } => with postgres on other server: slice: 23842.81 recs/sec bind: 27994.01 recs/sec with postgres on local server: slice: 214963.65 recs/sec bind: 505370.38 recs/sec

YMMV


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^3: DBI Hash of Column name values
by derby (Abbot) on Aug 10, 2010 at 12:37 UTC

    Interesting ... YMMV most definitely. Not sure if it's due to a difference in the databases, or the drivers or the data itself ... but using your approach against a 43 col table (mixed data types), I get:

    slice: 14021.59 recs/sec bind: 6750.10 recs/sec

    -derby

      For the local compare, where bind was twice as fast as slice, I used:

      Linux 2.6.31.12-0.2 x86_64 CPU Core(TM) i5 CPU 660 @ 3.33GHz/1199(2) Memory 7802 Mb perl 5.12.1 64bitall/longdouble DBI 1.613 DBD::Pg 2.17.1 Postgres 8.4.4

      Enjoy, Have FUN! H.Merijn
Re^3: DBI Hash of Column name values
by avrono (Novice) on Aug 09, 2010 at 21:03 UTC
    Note, my solution is using bind as suggested ...