Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 通过Hint改变where语句执行顺序

[TiDB Usage Environment] Production Environment
[TiDB Version] 5.4.3
[Reproduction Path] Operations performed that led to the issue
[Encountered Issue: Problem Phenomenon and Impact]
SELECT *
FROM table_a a LEFT JOIN table_b b ON a.user_id = b.user_id
WHERE a.a = ‘1’
AND b.b = ‘1’;
As shown in the SQL above, examining the execution plan of the above statement at different times yields two different results:
First result: Prioritizes executing the WHERE clause a.a=‘1’, execution speed is very fast;
Second result: Prioritizes executing the WHERE clause b.b=‘1’, execution speed is very slow;
Can we use a Hint to specify that the SQL statement should prioritize executing the WHERE clause a.a=‘1’ during execution?
[Resource Configuration] Navigate to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]