From 30cb7ad7ade74fc9364f06f271ed33e140fde498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jun 2021 17:05:31 +0300 Subject: [PATCH] Speed up MySQL inserts during prepare During sysbench prepare, let us use the same settings as mysqldump would, in an attempt to speed up INSERT operations. In MariaDB/server@8ea923f55b7666a359ac2c54f6c10e8609d16846 this would result in less undo log being written. --- src/lua/oltp_common.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua/oltp_common.lua b/src/lua/oltp_common.lua index fdc5c83ed..7ae36dc57 100644 --- a/src/lua/oltp_common.lua +++ b/src/lua/oltp_common.lua @@ -287,6 +287,10 @@ function prepare_commit() end function prepare_for_each_table(key) + if drv:name() == "mysql" + then + con:query("SET autocommit=0, unique_checks=0, foreign_key_checks=0") + end for t = 1, sysbench.opt.tables do stmt[t][key] = con:prepare(string.format(stmt_defs[key][1], t)) @@ -316,6 +320,10 @@ function prepare_for_each_table(key) stmt[t][key]:bind_param(unpack(param[t][key])) end end + if drv:name() == "mysql" + then + con:query("SET autocommit=1, unique_checks=1, foreign_key_checks=1") + end end function prepare_point_selects()