Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 判断条件有一个为空就会很慢,除了放在子查询有其他解决方案吗?
[TiDB Usage Environment] Production Environment
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]
Adding or not adding this line makes a huge performance difference
case.sql (4.7 KB)
Execution Plan without Empty Line.xlsx (12.8 KB)
Execution Plan with Empty Line.xlsx (13.6 KB)
Try manually analyzing the involved tables and then give it another shot.
First, use WITH to create a set, and then filtering will be faster.
Try collecting statistics.
If you don’t make a judgment, is the atdpersontimesheet table not even in the execution plan?
Take a look at the specific execution plan.
It seems that not only a WHERE condition was deleted, but the table is also gone. Did you get the wrong execution plan?
Check again if the SQL was sent incorrectly.
Can we replace the left join with an inner join in the sheet table here?
That condition directly affects the use of the index.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.