my $batchsize = 20; # tune this value my $count = 0; my $sth = $dbh->prepare('update myTable set va = ?, vb = ? where vc = ?'); $dbh=>begin_work; # or however you start a transaction; don't take my word on this line while (my $record = <$input>) { chomp $record; my ($va, $vb, $vc) = (split(/\|/, $record))[1, 3, 5}; $sth->execute($va, $vb, $vc); $count += 1; if ($count % $batchsize == 0) { $dbh->commit; # doublecheck the commit statement too $dbh->begin_work; } }