インサートをトランザクション内に配置することで、速度を大幅に向上させることができるはずです。準備ステートメントとバインドステートメントをループの外に移動することもできます。
$array = array("array", "with", "about", "2000", "values");
$query = "INSERT INTO table (link) VALUES (?)";
$stmt = $mysqli->prepare($query);
$stmt ->bind_param("s", $one);
$mysqli->query("START TRANSACTION");
foreach ($array as $one) {
$stmt->execute();
}
$stmt->close();
$mysqli->query("COMMIT");
このコードをWebサーバーで10,000回繰り返してテストしました。
トランザクションなし:226 seconds. トランザクションあり:2 seconds. または、two order of magnitude speed increase 、少なくともそのテストでは。