http://www.perlmonks.org?node_id=1041243


in reply to Re^3: DBI Style Inquiry
in thread DBI Style Inquiry

The difference between BC and DBC is the method-call overhead. If you really want to squeze out nonoseconds per call, it matters. It is not something I would propagate in use though:

Create table 5000 x 12 Dbindcol 660153.156 recs/sec 4.8 x faster DBC bindcol 633472.697 recs/sec 4.6 x faster BC Darrayref 563380.282 recs/sec 4.1 x faster DAR arrayref 525486.075 recs/sec 3.8 x faster AR array 227086.929 recs/sec 1.7 x faster A hashref 136836.344 recs/sec HR
{ $sth->execute; my ($n, $now) = (0, [ gettimeofday ]); while (my $ref = $sth->fetchrow_hashref) { ++$n % 100 == 0 and printf " %6d\r", $n; } report ("hashref", $n, $now); } { $sth->execute; my ($n, $now) = (0, [ gettimeofday ]); while (my @row = $sth->fetchrow_array) { ++$n % 100 == 0 and printf " %6d\r", $n; } report ("array", $n, $now); } { $sth->execute; my ($n, $now) = (0, [ gettimeofday ]); while (my $ref = $sth->fetchrow_arrayref) { ++$n % 100 == 0 and printf " %6d\r", $n; } report ("arrayref", $n, $now); } { $sth->execute; my ($n, $now) = (0, [ gettimeofday ]); while (my $ref = DBI::st::fetchrow_arrayref ($sth)) { ++$n % 100 == 0 and printf " %6d\r", $n; } report ("Darrayref", $n, $now); } my %ref; { $sth->execute; $sth->bind_columns (\(@ref{@{$sth->{NAME_lc}}})); my ($n, $now) = (0, [ gettimeofday ]); while ($sth->fetch) { ++$n % 100 == 0 and printf " %6d\r", $n; } report ("bindcol", $n, $now); } { $sth->execute; $sth->bind_columns (\(@ref{@{$sth->{NAME_lc}}})); my ($n, $now) = (0, [ gettimeofday ]); while (DBI::st::fetchrow_arrayref ($sth)) { ++$n % 100 == 0 and printf " %6d\r", $n; } report ("Dbindcol", $n, $now); }

Enjoy, Have FUN! H.Merijn