Bug #105068 | Type ref instead of range after reconsidering_access_paths_for_index_ordering. | ||
---|---|---|---|
Submitted: | 28 Sep 2021 22:06 | Modified: | 30 Sep 2021 15:00 |
Reporter: | Jean-François Gagné | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.7 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[28 Sep 2021 22:06]
Jean-François Gagné
[29 Sep 2021 11:42]
Øystein Grøvlen
I think this issue was fixed in 8.0.14 by the fix for Bug#28086754. The fix for this bug in 5.7.25 is slightly different and does not include the call to can_switch_from_ref_to_range() in test_if_skip_sort_order(). In other words, I think this bug will only appear in 5.7.
[29 Sep 2021 12:37]
MySQL Verification Team
Hi Mr. Gagne, Thank you for your bug report. In order to proceed with processing of the bug report we require a full test case. A test case that consists of a set of SQL statements that lead to the appearance of the bug. While we are waiting for the response from you, we shall analyse whether this behaviour will be fixed in 5.7 or not.
[29 Sep 2021 12:39]
MySQL Verification Team
Hi, To make ourselves more clear, your uploaded file does not contain any rows.
[29 Sep 2021 13:07]
Jean-François Gagné
Hi MySQL Verification Team, > In order to proceed with processing of the bug report we require a full test case. A test case that consists of a set of SQL statements that lead to the appearance of the bug. I think I already provide this in the private file I uploaded. I was hopping that the explain outputs and the optimizer trace would be enough to do a code analysis. Also, maybe what was provided by Øystein could be considered for finding this bug by code inspection. > To make ourselves more clear, your uploaded file does not contain any rows. I am able to see the content of the private file that I uploaded (2nd private comment, 45.07 KiB). This file contains a little more data than what I can publicly disclose (table structure and SQL statements), but the dataset is not shared (production / customer data - 16 GB ibd file) and the statistics on the table are not shared either (I do not know hot to extract this from my production db and inject this back in my test environment, which could lead to a reproduction with 5.7.25 non-prod, 5.7.35 and maybe with 8.0.26). Hopefully, we can work together to narrow this down with the data already shared publicly and privately, and I am at your disposition to provide more information (public or private), just let me know what would help. Best regards, Jean-François Gagné
[29 Sep 2021 13:13]
MySQL Verification Team
Hi, We have looked at all data that you have sent us and there are no rows that will help us repeat the behaviour. We do accept code analysis, with pinpoint of the error in our code, but we have not received that either from you. Meanwhile, we shall investigate whether this is fixed or not in 8.0.
[29 Sep 2021 20:07]
Øystein Grøvlen
The following test case, seems to reproduce the problem: create table t1(pk int auto_increment primary key, a int, b int, c int, key (a, b), key (c)); insert into t1(a, b, c) values (1,1,1), (1,2,2), (1,3,3), (1,4,4), (1,5,5), (2,1,6), (2,2,7), (2,3,8), (2,4,9), (2,5,10); insert into t1(a,b,c) select a,b,c from t1; insert into t1(a,b,c) select a,b,c from t1; insert into t1(a,b,c) select a,b,c from t1; analyze table t1; explain select * from t1 where a=1 and b>1 and c<2 order by b desc LIMIT 1; EXPLAIN output: mysql [localhost:5732] {msandbox} (test) > explain select * from t1 where a=1 and b>1 and c<2 order by b desc LIMIT 1; +----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+ | 1 | SIMPLE | t1 | NULL | ref | a,c | a | 5 | const | 40 | 3.33 | Using where | +----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+ 1 row in set, 1 warning (0.00 sec) As you can see, ref is used here even if it is possible to use range on more keyparts.
[29 Sep 2021 20:31]
Jean-François Gagné
I am a little embarrassed, and it looks like I own excuses... I was not able to reproduce after importing the ibd in 5.7-latest and 8.0-latest and in 5.7.25 for a good reason, and not because of statistics... I was able to reproduce in *Percona Server* 5.7-latest and have to confess that this behavior was not happening in MySQL 5.7.25 but in Percona Server 5.7.25. :-S Thanks to Øystein for pointing-out that my full optimizer trace was including things that were not in MySQL 5.7. From Øystein reproduction, it still looks like there is something to be fixed in MySQL 5.7, I am not sure what is the best way forward here: keeping this bug open for Øystein findings or opening a new bug. (I will post a link to PS bug after opening it.) I am very sorry for having wasted your time.
[30 Sep 2021 12:23]
MySQL Verification Team
Hi All, This bug is fixed in our version 8.0 and it will not be analysed nor fixed in any of the previous versions, even if it would surface ...... Thank you both for your contribution.
[30 Sep 2021 12:37]
MySQL Verification Team
Hi, After additional analysis, it was decided that this bug will be verified as affecting only version 5.7. Verified as 5.7-only bug .....
[30 Sep 2021 14:51]
Jean-François Gagné
This might be a duplicate of Bug#92850.
[4 Oct 2021 12:07]
MySQL Verification Team
Merci, Jean-Francois !!!!