LAMP / MySQL-SQL批处理插入期间的运行时间延迟

时间:2020-08-24 18:55:18

标签: mysql performance lamp query-performance

我有一条SQL批处理插入语句,该语句已正确插入索引并通过explain进行了验证。我正在使用批处理插入创建73行。作为批处理插入的一部分,我在每个插入的记录上使用NOW()记录日期/时间戳。

在插入过程中,插入68条记录后,创建其余5条记录会有50秒的延迟。

在插入过程中可能导致延迟的原因是什么?我应该检查哪些日志?

$values = "";
foreach ($recipients as $recipient) {
    $values = $values . "(" .
              $msg['msg_id'] . "," .
              $recipient['mbr_id'] . "," .
              "NOW()" . "),";
}

// remove the last comma from the value list to terminate the values list
$values = rtrim($values, ",");

$sql = "INSERT INTO message (message_id, member_id, create_dtm)
        VALUES " . $values;

// internal library function using PDO to write to the database 
$pdb->db_commit($sql);  

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

感谢有关innodb_lock_wait_timeout的评论,我发现必须为MySql分配更多的内存。