単一のクエリとして実行してみませんか?
$SQL = "INSERT INTO mytable2 (col1,col2) SELECT val1,val2 FROM mytable";
$query = mysql_query($SQL);
別
INSERT200を一度に調整することもできます
$query = mysql_query("SELECT * FROM mytable");
$commit_count = 0;
$commit_limit = 200;
$comma = "";
$SQL = "INSERT INTO mytable2 (col1, col2) VALUES ";
while($row = mysql_fetch_assoc($query)){
$SQL .= $comma . "('".$row['val1']."','".$row['val2']."')";
$comma = ",";
$commit_count++;
if ( $commit_count == $commit_limit )
{
mysql_query($SQL);
$SQL = "INSERT INTO mytable2 (col1, col2) VALUES ";
$commit_count = 0;
$comma = "";
}
}
if ( $commit_count > 0 ) { mysql_query($SQL); }
$commit_limit
を妥当な正の数に変更できます。