The fastest way to get strings as hashes using DBI is to use bind_columns() as follows:
$sth->execute; my %row; $sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } )); while ($sth->fetch) { print "$row{region}: $row{sales}\n"; }
This is only suitable if you are happy that each line reuses the same hash.
Other than that, I agree with davorg, avoid guesswork: first measure.
For more information about using DBI, including performance, see the training slides section (since 2007, but still relevant).
source share