The question is about SQL
legacy code for MySQL
database.
It is known, that when doing INSERT ... ON DUPLICATE KEY UPDATE
statement VALUES(col_name)
function can be used to refer to column values from the INSERT portion instead of passing there exact values:
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c)
My legacy code contains a lot of huge inserts in parametrized style (they are used in batch-inserts):
INSERT INTO table (a,b,c, <...dozens of params...>) VALUES (?,?,?,<...dozens of values...>)
ON DUPLICATE KEY UPDATE b=?, c=?, <...dozens of params...>
The question is: would it increase performance of batch-inserts if I will change all these queries to use VALUES(col_name)
function (in UPDATE
portion)?
My queries are executed from java code using jdbc
driver. So, what I guess, is that for long text values it should significantly reduce size of queries. What about MySQL
it self? Would it really in general give me increasing of speed?