Do more with less!
 
 
- Reduce the number of DBI calls
- 
- The DBI is fast -- but it isn’t free!
- 
 
- Using RaiseError is faster than checking return values
- 
- and much faster than checking $DBI::err or $h->err
- 
 
- Using fetchall_arrayref (or selectall_arrayref) is now much faster
- 
- if using a driver extension compiled with the DBI’s Driver.xst wrapper (most are) 
- because the loop is written in C and doesn’t make a method call per row
- 
 
- Using fetchall_arrayref is possible for very large result sets
- 
- new $max_rows parameter limits rows returned (and memory consumed)
- just add an outer loop to process the results in ‘batches’, or do it in-line:
 $row = shift(@$cache)
 || shift @{$cache=$sth->fetchall_arrayref(undef, 1000)};