Bug #118723 optimize for innodb insert
Submitted: 26 Jul 11:54 Modified: 28 Jul 4:27
Reporter: alex xing (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:8.0.42 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[26 Jul 11:54] alex xing
Description:
We are performing high-concurrency INSERT operations on a large table with many columns. Perf analysis reveals that rec_get_converted_size_comp consumes a significant amount of CPU.

Upon analyzing the code, we discovered that rec_get_converted_size_comp is called twice during a single page insertion. Since the table has a large number of columns, this function involves extensive traversal operations, leading to performance overhead.

The pre-optimization logic is as follows:

page_cur_tuple_insert
|--> rec_get_converted_size
|  |--> return(rec_get_converted_size_comp(...));
|--> rec_convert_dtuple_to_rec
|  |--> rec_convert_dtuple_to_rec_new
|  |  |--> //This call is only to compute extra_size 
|  |  |--> rec_get_converted_size_comp(.., &extra_size)

How to repeat:
just read the code

Suggested fix:
We can store the extra_size in the return value of rec_get_converted_size and pass it to rec_convert_dtuple_to_rec.
Additionally, since the cost of obtaining extra_size in the old format is minimal, this commit does not include optimizations for it.
[26 Jul 11:55] alex xing
a simple patch to describe the optimization

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: innodb_insert.optimize (application/octet-stream, text), 3.59 KiB.

[28 Jul 4:27] MySQL Verification Team
Hello Alex Xing,

Thank you for the report and contribution.

regards,
umesh