##
while ( @columns = $sth1->fetchrow_array ) {
$inserted += $sth2->execute(@columns);
...
}
}
####
while ($row=shift(@$cache) || shift@{$cache=$sth_o->fetchall_arrayref(undef,$max_rows) || []}) {
$inserted += $sth2->execute(@$row);
...
};