-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
planner does not reorder the inner joins simplified from outer joins #22384
Labels
Comments
MySQL shows rewritten statements with mysql [localhost:8022] {msandbox} (test) > EXPLAIN
-> SELECT t1.pk
-> FROM t1
-> LEFT JOIN t2 ON t1.col1 = t2.pk
-> LEFT JOIN t3 ON t1.col3 = t3.pk
-> WHERE
-> t2.col1 IN ('a' , 'b')
-> AND t3.keycol = 'c'
-> AND t1.col2 = 'a'
-> AND t1.col1 != 'abcdef'
-> AND t1.col1 != 'aaaaaa';
+----+-------------+-------+------------+--------+-----------------------+---------+---------+--------------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+--------+-----------------------+---------+---------+--------------+------+----------+-------------+
| 1 | SIMPLE | t1 | NULL | ref | col1,col3,col2,col1_2 | col2 | 163 | const | 1 | 100.00 | Using where |
| 1 | SIMPLE | t3 | NULL | eq_ref | PRIMARY,keycol | PRIMARY | 128 | test.t1.col3 | 1 | 100.00 | Using where |
| 1 | SIMPLE | t2 | NULL | eq_ref | PRIMARY | PRIMARY | 128 | test.t1.col1 | 1 | 100.00 | Using where |
+----+-------------+-------+------------+--------+-----------------------+---------+---------+--------------+------+----------+-------------+
3 rows in set, 1 warning (0.00 sec)
mysql [localhost:8022] {msandbox} (test) > SHOW WARNINGS;
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Note | 1003 | /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`pk` = `test`.`t1`.`col1`) and (`test`.`t3`.`pk` = `test`.`t1`.`col3`) and (`test`.`t1`.`col2` = 'a') and (`test`.`t3`.`keycol` = 'c') and (`test`.`t2`.`col1` in ('a','b')) and (`test`.`t1`.`col1` <> 'abcdef') and (`test`.`t1`.`col1` <> 'aaaaaa')) |
+-------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec) |
Closed
Please edit this comment or add a new comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA) (optional)2. Symptom (optional)3. All Trigger Conditions (optional)4. Workaround (optional)5. Affected versions[v4.0.0:v4.0.10], [v5.0.0-rc] 6. Fixed versionsmaster |
This was referenced Jan 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
I expect the same result in
EXPLAIN
as when i manually convert the query toINNER JOIN
.3. What did you see instead (Required)
TiDB does not seem to do this though, and the
EXPLAIN
can be seen as different:4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: