On Mon, Nov 06, 2006 at 04:08:40PM -0000, [EMAIL PROTECTED] wrote:
> On 6 Nov 2006 at 15:08, Also Sprach Tim Bunce:
> 
> > Exactly. Also keep in mind the combined approach using bind_columns:
> > 
> >              $sth->execute;
> >              my %row;
> >              $sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } ));
> >              while ($sth->fetch) {
> >                  print "$row{region}: $row{sales}\n";
> >              }
> 
> Ah. Thanks. Just what I'm after!
> But doesn't fetchrow_hashref do this, and more efficiently?

No. On each call to fetchrow_hashref it has to FETCH the NAME attribute
to get the keys to use for the hash. That's what makes fetchrow_hashref
significantly slower than non-hash fetching.

See the bottom half of page 24 in
http://backpan.perl.org/authors/id/T/TI/TIMB/DBI_AdvancedTalk_200608.pdf
for a (slightly obtuse) comparison of selectall_arrayref vs
selectall_hashref vs prepare+execute+fetch loop.

Tim.

Reply via email to