Bug #118173 The insert statement suffers a performance penalty after commit cd66c5c.

Submitted: 13 May 2025 6:42 Modified: 2 Jul 2025 2:03
Reporter: jinze si Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S5 (Performance)
Version:8.0.42 OS:Ubuntu (22.04)
Assigned to: CPU Architecture:x86
Tags: performance regression

[13 May 2025 6:42] jinze si
Description:
After commit cd66c5c, we find that mysql suffers a performance degradation when executing some INSERT statements, here's an example statement:
```
INSERT INTO users SET id = 1, username = 'user1', email = 'user1@example.com' ON DUPLICATE KEY UPDATE email = 'updated_user1@example.com';
```

We tested it using mysqlslap with the following test statement:
```
 ./mysqlslap --concurrency=1 --iterations=1 --create-schema=test --query="$mysql_inst" -uroot -S $(pwd)/bin/mysql.sock --number-of-queries=1000000
```
The result of the test statement is as follows:

After cd66c5c:
        Average number of seconds to run all queries: 31.304 seconds
	Minimum number of seconds to run all queries: 31.304 seconds
	Maximum number of seconds to run all queries: 31.304 seconds
	Number of clients running queries: 1
	Average number of queries per client: 1000000

Before cd66c5c:
        Average number of seconds to run all queries: 30.052 seconds
	Minimum number of seconds to run all queries: 30.052 seconds
	Maximum number of seconds to run all queries: 30.052 seconds
	Number of clients running queries: 1
	Average number of queries per client: 1000000

How to repeat:
We provide our pre-populated data and simply execute the insert statement we provided above

Suggested fix:
We found that commit cd66c5c fixed a bug when updating row with empty_sql mode. It changed the logic of insert, so is it possible that this is causing a drop in performance.
[13 May 2025 12:46] jinze si
update OS
[1 Jul 2025 14:04] MySQL Verification Team
Can you share also server details
- number of cores and cpu's
- amount of ram

Thanks
[2 Jul 2025 2:03] jinze si
OK,here are the server details

cat /proc/cpuinfo | grep processor | wc -l
128

cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l
2

cat /proc/meminfo | grep MemTotal
MemTotal:       527702240 kB

Also, our linux kernel is 5.15.0-76-generic(ubuntu~22.04.1)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.046 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.