Optimization of Slow SQL in TiDB

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

Original topic: TIDB自身的慢SQL优化

| username: TiDBer_pkQ5q1l0

[TiDB Usage Environment] Production Environment
[TiDB Version] 5.2.1
[Encountered Problem: Phenomenon and Impact]
The dashboard shows many slow SQL queries generated by the system itself, as shown below.


How can this be optimized?
image

| username: 像风一样的男子 | Original post link

You can clean up the slow SQL logs. Over time, they accumulate too much, which will definitely slow down the queries. The logs are located in the log folder under the TiDB node on the server.

| username: TiDBer_pkQ5q1l0 | Original post link

I have already cleaned up the slow_query_log-xxx.

| username: Kongdom | Original post link

:thinking: Maybe you can check the execution plan. If the execution plan is not as expected, you can request modifications.

| username: tidb菜鸟一只 | Original post link

Check the execution plan; the digest column should have an index.

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

It does not affect usage, no optimization needed.

| username: Jellybean | Original post link

Earlier lower versions may have this issue. If it does not interfere with business, it can be ignored. If it has an impact, consider upgrading to a higher version.

| username: 春风十里 | Original post link

This can only be upgraded, right? I wonder if SQL Binding can be used.

| username: dba远航 | Original post link

Normal, I have it too.