TiDB is very slow

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

Original topic: tidb速度很慢

| username: TiDBer_9zQsWzfW

[Test Environment] Testing environment
[TiDB Version] v8.0.0
[Reproduction Path] TiDB installed via k8s
[Encountered Issue: Problem Phenomenon and Impact] Insertion speed is abnormally slow
[Resource Configuration]

[Attachments: Screenshots/Logs/Monitoring]

| username: 有猫万事足 | Original post link

The average maximum for insert is only 20ms.

What level of optimization would be acceptable to you?

| username: yytest | Original post link

You need to check the execution plan of the statement.

| username: TIDB-Learner | Original post link

From the screenshot, it doesn’t seem slow. What is it being compared to that makes it seem slow?

| username: DBAER | Original post link

Is it possible to insert multiple values into xx?

| username: TiDBer_RjzUpGDL | Original post link

This insertion is not slow.

| username: Kongdom | Original post link

:joy: The sorted column is the cumulative time, which is the execution time of all similar statements combined, not the execution time of a single statement. If you want to see which specific statement is slow, you can check the slow query section.

| username: lemonade010 | Original post link

How is slowness defined? Is it referring to individual queries or the overall time? The execution time of the SQL query is at most 19ms, which doesn’t seem to be a problem.

| username: TiDBer_QYr0vohO | Original post link

This isn’t considered slow.

| username: TiDBer_rvITcue9 | Original post link

Why are your environment requirements so high?

| username: zhh_912 | Original post link

First, check the relevant logs of the operating system and the database to see if you can find any useful information.

| username: 小于同学 | Original post link

The insertion speed is acceptable.

| username: 小龙虾爱大龙虾 | Original post link

From the first INSERT, the average time is 19 ms, executed 45k times, which is somewhat slow and has some long-tail latency.

  1. Is the TiDB cluster configured according to the official recommendations?
  2. How is the pressure on each node of the cluster? Are there any resources fully utilized or any resource skew (hotspot) situations?
  3. What is the row length of the INSERT? Can you use INSERT xxx values (),(),() to insert multiple rows at once?
| username: 像风一样的男子 | Original post link

My average time for high-concurrency data insertion is 5 milliseconds.

| username: Jack-li | Original post link

This isn’t slow, but it can be optimized. Check the logs.

| username: tony5413 | Original post link

From the screenshot, the inserts are all in milliseconds.

| username: changpeng75 | Original post link

A performance of 20ms is indeed not high, especially considering the benefits of TiDB’s distributed nature for large data volumes, it’s even less impressive. However, the original poster’s description of the environment is too simplistic, making it difficult to pinpoint the issue. It might just be that the hardware itself is underperforming.

| username: zhh_912 | Original post link

Check if the data volume is large or if there is an issue with the SQL?

| username: FutureDB | Original post link

Is it possible to convert inserts into batch inserts as much as possible to reduce the number of network interactions between the client and the database?