Hot handles
Avoid using $dbh->do(…) in a speed-critical loop.
Use $sth = $dbh->prepare(…)
and $sth->execute() instead.
Using prepare() gets a handle on the statement in the SQL cache and keeps it there.
Using the handle for the pre-prepared statement avoids a round-trip to server for SQL cache-check / parsing etc.
For example, convert looped
do("insert … ?", undef, $id)
to prepare("insert … ?")and looped execute($id)
This often gives a significant performance boost