Slow INSERT statement

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: insert语句慢

| username: jingyesi3401

[TiDB Usage Environment] Production Environment, Testing

[TiDB Version] v5.1.0

[Encountered Problem: Problem Phenomenon and Impact]
Found slow SQL queries where some databases take over ten seconds to execute insert statements, resulting in very low consumption capacity for the entire database. Other larger queries (with more field values) are actually faster.

Figure 1: Time-consuming insert statement

Figure 2: Execution time of the time-consuming insert statement

Figure 3: Manual execution time is very fast

Figure 4: Heatmap

| username: Billmay表妹 | Original post link

Refer to this.

| username: wluckdog | Original post link

Let’s take a look at the overview information.

| username: jingyesi3401 | Original post link

| username: 裤衩儿飞上天 | Original post link

Does the purple line on the heatmap correspond to the related table?

| username: wluckdog | Original post link

Is the primary key ID of the table structure auto-incrementing? High concurrency leads to slow ID allocation??? Check the issue from the design of the primary key in the table structure.