Anomaly Detected in SQL Statement Analysis on TiDB Dashboard

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

Original topic: TIDB DASHbord 中 SQL语句分析出现异常

| username: TiDBer_bOR8eMEn

[TiDB Usage Environment] Production Environment
[TiDB Version] 5.2.3
[Reproduction Path]

The cumulative time and execution count keep adding up. Is there any issue with this?
Where can I see the reported warnings?

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

No problem.

tidb_stmt_summary_max_stmt_count controls the number of SQL types saved in the Statement Summary system table. When the number of SQL types exceeds this value, the SQL that has not appeared recently will be removed.

An average response time of 17.8ms is quite fast.

| username: TiDBer_bOR8eMEn | Original post link

Why are there so many executions here?

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

For example, if there are 10 types of SQL and your tidb_stmt_summary_max_stmt_count is set to 3, the remaining 7 types will be counted in “others.”

The execution counts of these 7 types will also be aggregated together. So from a long-tail perspective, this should comply with the 80/20 rule. Having 80% of the statistics in “others” is quite normal. These execution counts will definitely not be small.

For system optimization, you should not be distracted by these SQL statements that do not have issues.

| username: TiDBer_bOR8eMEn | Original post link

The second line, that SQL is executed many times, not in others.

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

This SQL is very specific and related to your business. If it doesn’t meet your expectations, you can ask your developers. I can’t determine whether it needs to be executed so many times.

| username: zhaokede | Original post link

Asking the developers to check the code might also be related to scheduled tasks within the business code, which are executed periodically multiple times.

| username: TiDBer_bOR8eMEn | Original post link

Got it, thank you everyone.