In trying to optimize my code, I discovered that I was using an unnecessarily long method of prepare -> execute -> fetchrow_array when getting 1 row of information. It's faster to code and process to use:
($colA, $colB) = $dbh->selectrow_array("SELECT * FROM table WHERE foo=? LIMIT 1", undef,
'bar');
Which function is best when I need to retrieve multiple rows, though? I'm currently using the lengthier method, so I'm just trying to shorten it (and wouldn't mind if it processes faster):
$sth = $dbh->prepare("SELECT * FROM table WHERE foo=? LIMIT 10");
$sth->execute('bar');
while (($colA, $colB) = $sth->fetchrow_array()) {
# whatever
}