Questions about Execution Plan

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

Original topic: 执行计划疑问

| username: 等一分钟

From this information, can we tell if the bottleneck is with TiDB or TiKV?

| username: TIDB-Learner | Original post link

Operator pushdown, this is TiKV, the module for reading data and computation.

| username: 等一分钟 | Original post link

The slow execution is in the TiKV part, right?

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

SQL consumes a lot of resources, optimizing SQL will solve the problem.

| username: 等一分钟 | Original post link

If you need to add hardware resources, should you add CPU or memory for TiKV?

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

First, take a look at the SQL. If the SQL is not good, nothing else will be useful.

| username: 等一分钟 | Original post link

No way, even stacking hardware doesn’t work?

| username: h5n1 | Original post link

Cop tasks are statistics on the TiKV side, possibly due to a large amount of scanned data: either the query itself requires a lot of data or there are many MVCC versions to scan. You can check the total_keys information in the execution plan. It could also be that the unified thread pool is quite busy, leading to longer times.

| username: 等一分钟 | Original post link

During the month-end, during peak concurrency, there are too many SQL queries, and it’s also difficult to modify them.

| username: 等一分钟 | Original post link

The image you provided is not visible. Please provide the text you need translated.

| username: 等一分钟 | Original post link

Is the amount of data read from TiKV too large?
Can increasing memory and cache help alleviate this?

I see that the CPU usage of tidb_server is also very high. I’m not sure if the bottleneck is with tidb_server or TiKV.

| username: h5n1 | Original post link

There are quite a few MVCC versions. Check the tikv-detail thread CPU and unify read pool monitoring when executing SQL.

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

Please provide the SQL and the execution plan.

| username: 等一分钟 | Original post link

Assuming SQL cannot be optimized, how can we solve the problem of slow queries? You can add resources.

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

Increase operator parallelism, and if TiKV resources are insufficient, add more TiKV machines.

| username: 等一分钟 | Original post link

Is it adding TiKV nodes or upgrading TiKV configurations?

| username: 等一分钟 | Original post link

Yesterday, I added a node, but it takes a long time to synchronize data, so the problem cannot be solved immediately.

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

Scaling a distributed database is definitely done horizontally, and it is expanded when there are bottlenecks.

| username: 烂番薯0 | Original post link

Add more TiKV nodes or increase the configuration of TiKV.

| username: WalterWj | Original post link

Optimizing SQL? Are you sure you need to scan that much data…