my $sth_i = $dbh->prepare_cached( "INSERT INTO foo (bar, baz,qux) VALUES(?,?,?)" ); # or my $sth_u = $dbh->prepare_cached( "UPDATE foo SET bar = ?, baz = ? WHERE qux = ?" ); # make it easy on perl ie declare loop vars outside loop to save create/destroy # yes it should be optimised but it seems to help speed/memory consumption my @fields; # delete irrelevant indexes here before we start the load open IN, $infile or die $!; while() { @field = split "\t"; # fail fast if you don't want to do anything - even before you chomp # lots of loops so every little bit of saving helps $sth_i->execute(@fields[0..2]); } # recreate indexes so you are not wasting time doing partial indexing