Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 针对慢sql的优化方向
[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 6.0
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issues: Problem Phenomenon and Impact] The SQL query is slow, and the speed of inserting collected data into a certain table is very slow. What are the optimization directions for SQL? Also, regarding the priority of operator efficiency, I hope the experts can rank them. I now understand why various operators appear there, but I don’t know which operator is optimal for different data volumes, such as table joins. As a newbie to databases, I hope the experts can provide some guidance.
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]
You can refer to the SOP written by community experts:
Additionally, the official documentation also provides a detailed explanation:
However, it is best to provide an example and analyze it case by case.
The image is not available for translation. Please provide the text content directly.
This is an example, I want to know the optimization direction.
Are there any articles about SOP? I’d like to study them.
Do you have any good optimization suggestions for this kind of group by and order by?
It’s the ones shared above
Go straight to TiFlash, simple and straightforward.
Such a comprehensive article, thank you.
Currently, there is no TiFlash instance deployed.
It is recommended to first explain and look at the execution plan. If the statistics are inaccurate, gather the statistics first. By looking at the execution plan, you can see where the bottleneck is, and then analyze it accordingly.
Looking at your SQL, it is actually not complicated. It just has many case when statements and calculated fields in the select clause. Additionally, there are group and order clauses. Check the execution plan to evaluate the indexes and data volume involved. Establishing appropriate indexes should be effective.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.