Bug #99381 | ORDER_BY Index-level optimizer hint implies NO_JOIN_INDEX for second table | ||
---|---|---|---|
Submitted: | 28 Apr 2020 7:26 | Modified: | 29 Apr 2020 7:05 |
Reporter: | Jesper Wisborg Krogh | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 8.0.20 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[28 Apr 2020 7:26]
Jesper Wisborg Krogh
[28 Apr 2020 7:26]
Jesper Wisborg Krogh
Workaround, to get the expected query plan back, you need to add a JOIN_INDEX() hint as well: EXPLAIN SELECT /*+ ORDER_INDEX(ci CountryCode) JOIN_INDEX(ci CountryCode) */ ci.CountryCode, co.Name AS Country, ci.Name AS City, ci.District FROM world.country co INNER JOIN world.city ci ON ci.CountryCode = co.Code WHERE co.Continent = 'Asia' ORDER BY ci.CountryCode, ci.ID\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: co partitions: NULL type: ALL possible_keys: PRIMARY key: NULL key_len: NULL ref: NULL rows: 239 filtered: 14.285715103149414 Extra: Using where; Using temporary; Using filesort *************************** 2. row *************************** id: 1 select_type: SIMPLE table: ci partitions: NULL type: ref possible_keys: CountryCode key: CountryCode key_len: 3 ref: world.co.Code rows: 18 filtered: 100 Extra: NULL 2 rows in set, 1 warning (0.0008 sec)
[29 Apr 2020 7:05]
MySQL Verification Team
Dear Jesper, Thank you for the report and feedback. regards, Umesh