Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: LEFT JOIN 不走索引的问题
【TiDB Usage Environment】Production Environment
【TiDB Version】7.5.0
【Reproduction Path】Operations performed that led to the issue
【Encountered Issue: Problem Phenomenon and Impact】
The kid in table A is the primary key, and the kid in table B is a normal index. During the join query, the index of table A cannot be hit. Both tables A and B have around 13 million records.
【Resource Configuration】Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
【Attachments: Screenshots/Logs/Monitoring】
Too much is hidden, can’t see anything. Check the data types of the associated columns and the table’s character set collation.
Try adding the hint /*+ INL_JOIN(fjxx, info) */, but the efficiency should be worse than your current execution plan.
I tried it, and the execution plan is the same.
Okay, I checked the collation of the fields and found they were inconsistent. After making them consistent, it worked. Thank you, thank you.
Check if the character sets and field types of the two tables are the same.
If there is no index, create an index; if there is an index, check the character set and collation.
Yes, the character set of the fields must be the same, and the collation must be the same, so that it is possible to use index association.