Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: TiDB 索引优化器异常
[TiDB Cluster Information]
- Version: v5.1.1
- TiDB Instances: 2
[Encountered Issues]
-
Currently, there are two TiDB instances. Yesterday, a slow query alert appeared, and it was found that one of the TiDB instances executed a certain SQL query very slowly (over 1000s), while the other TiDB instance executed the same SQL query normally.
-
Analyzing the slow query logs, this SQL query used different indexes on the two TiDB instances, resulting in a significant difference in query speed:
- TiDB (1.20) used the wrong index
- TiDB (1.21) used the correct index
[Questions]
The configurations and parameters of the two TiDB instances are identical. Why is there a difference in index selection?