Symfony mariaDB批量更新非常慢

Symfony mariaDB批量更新非常慢,symfony,doctrine,mariadb,Symfony,Doctrine,Mariadb,我需要从数据库中的csv文件中更新290000行 我在每行上创建了一个循环来进行更新,任务如下所示: UPDATE lines_table INNER JOIN account ON lines_table.account_id = account.id SET account.is_updated = 1 WHERE account.is_updated = 1 AND lines_table.user_id=XXXXX AND lines_table.code = 'YY'; AND acc

我需要从数据库中的csv文件中更新290000行

我在每行上创建了一个循环来进行更新,任务如下所示:

UPDATE lines_table
INNER JOIN account ON lines_table.account_id = account.id
SET account.is_updated = 1
WHERE account.is_updated = 1
AND lines_table.user_id=XXXXX
AND lines_table.code = 'YY';
AND account.compte 'ZZZZZZZ';
$conn = $this->em->getConnection();
while (([$key, $account, $user] = fgetcsv($handle, 1000, ';')) !== false) {
    $stmt = $conn->prepare($sql);
    $stmt->execute();
}
php循环如下所示:

UPDATE lines_table
INNER JOIN account ON lines_table.account_id = account.id
SET account.is_updated = 1
WHERE account.is_updated = 1
AND lines_table.user_id=XXXXX
AND lines_table.code = 'YY';
AND account.compte 'ZZZZZZZ';
$conn = $this->em->getConnection();
while (([$key, $account, $user] = fgetcsv($handle, 1000, ';')) !== false) {
    $stmt = $conn->prepare($sql);
    $stmt->execute();
}
在我的电脑上(wamp+symfony3+SSD+mariaDB),它每秒更新85行

当我在测试环境(linux+symfony3+48 HDD 10k rpm,mariaDB)中执行此循环时,它每秒仅更新4行


是否有一个配置可能会有所不同并使循环变慢?

请使用事务,而不是对每一行执行查询。它将节省大量时间准备一次,执行多次。或者是否有任何原因需要在循环中重新编写语句?