Bug #110971 | Optimizer: reverse index scan doesn't affect the cost | ||
---|---|---|---|
Submitted: | 10 May 2023 3:21 | Modified: | 10 May 2023 7:50 |
Reporter: | Ilya Kantor | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S5 (Performance) |
Version: | 8.0.33 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[10 May 2023 3:21]
Ilya Kantor
[10 May 2023 3:21]
Ilya Kantor
Explains: mysql> explain analyze select id from users force index(idx_users_name_created_at) -> where name='Ann' order by created_at desc limit 10; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | EXPLAIN | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | -> Limit: 10 row(s) (cost=5257 rows=10) (actual time=0.0573..0.0623 rows=10 loops=1) -> Covering index lookup on users using idx_users_name_created_at (name='Ann') (reverse) (cost=5257 rows=39744) (actual time=0.0566..0.0604 rows=10 loops=1) | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> mysql> explain analyze select id from users force index(idx_users_name_created_at_desc) -> where name='Ann' order by created_at desc limit 10; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | EXPLAIN | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | -> Limit: 10 row(s) (cost=5257 rows=10) (actual time=0.0435..0.0469 rows=10 loops=1) -> Covering index lookup on users using idx_users_name_created_at_desc (name='Ann') (cost=5257 rows=39744) (actual time=0.043..0.0452 rows=10 loops=1) | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
[10 May 2023 7:50]
MySQL Verification Team
Hello Ilya Kantor, Thank you for the report and test case. regards, Umesh