Issues with Slow Queries in TiDB

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

Original topic: tidb查询慢的问题

| username: Fly-bird

[TiDB Usage Environment] Production Environment
[TiDB Version] 5.4
[Reproduction Path] Always present
[Encountered Problem: Phenomenon and Impact] We have an SQL query that takes 0.6s when run individually, but in the production environment, when there are multiple queries, the time increases to 12s or more (this does not always happen, it occurs during peak business hours when there are multiple queries). How can we troubleshoot this?
[Resource Configuration] tidb4 (8 cores 16G), PD3 (4 cores 8G), TIKV7 (16 cores 64G physical disk)
[Attachment: Screenshot/Log/Monitoring] The SQL statement is: SELECT COUNT(
) FROM t_feed_essay fe LEFT JOIN t_follow_person fp ON fe.user_id = fp.user_id WHERE fp.fans_id = 4611686018431039853 AND fe.delete_flag = 0 AND fe.status = 0 AND fp.del_flag = 0 AND fe.iz_to_feedback = 0;

| username: TiDBer_oHSwKxOH | Original post link

It feels like a cloud issue.

| username: 昵称想不起来了 | Original post link

During peak periods, it feels necessary to check the monitoring and refer to the expert documentation for troubleshooting.
Quickly Bookmark! Summary of Troubleshooting Ideas for Slow TiDB Read and Write Performance

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

Find the execution plan from that time, and you will quickly have a clear conclusion.

| username: dba-kit | Original post link

Is there a dashboard set up? I remember there was a bug in TiDB before, where the statistics information would fail to load easily, causing it to use pseudo logic and choose the wrong index. Check the execution plans of those timed-out SQL queries.

| username: dba-kit | Original post link

This parameter is set to “on” by default in version 5.4, but it has been changed to “off” in subsequent versions.

| username: dba-kit | Original post link

Take a look at these two parameters as well.

| username: yulei7633 | Original post link

To analyze SQL, you need an execution plan.

| username: yulei7633 | Original post link

Post the execution plan and let’s take a look.

| username: cy6301567 | Original post link

Check the execution plan and the TiDB monitoring to see if other slow SQL queries are affecting the overall execution efficiency of the cluster.

| username: 胡杨树旁 | Original post link

Check the SQL statement analysis to see if this SQL has multiple execution plans.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.