Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
12.1
-
None
-
Not for Release Notes
-
Q3/2025 Server Development
Description
In case below NO_INDEX(t1 a) can't resolve index name and instead of the hint being ignored it disables all indexes.
Testcase:
CREATE TABLE t1 ( |
a INT, |
b INT, |
PRIMARY KEY(a), |
KEY ab(a, b) |
);
|
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); |
INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; |
INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; |
INSERT INTO t1 SELECT a +16, b +16 FROM t1; |
INSERT INTO t1 SELECT a +32, b +32 FROM t1; |
INSERT INTO t1 SELECT a +64, b +64 FROM t1; |
|
|
analyze table t1; |
|
|
EXPLAIN EXTENDED SELECT a FROM t1 GROUP BY a; |
EXPLAIN EXTENDED SELECT/*+ NO_INDEX(t1 PRIMARY) */ a FROM t1 GROUP BY a; |
EXPLAIN EXTENDED SELECT/*+ NO_INDEX(t1) */ a FROM t1 GROUP BY a; |
EXPLAIN EXTENDED SELECT/*+ NO_INDEX(t1 a) */ a FROM t1 GROUP BY a; |
|
|
drop table t1; |
Actual result:
EXPLAIN EXTENDED SELECT a FROM t1 GROUP BY a; |
id select_type table type possible_keys key key_len ref rows filtered Extra |
1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 100.00 Using index |
Warnings:
|
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` |
EXPLAIN EXTENDED SELECT/*+ NO_INDEX(t1 PRIMARY) */ a FROM t1 GROUP BY a; |
id select_type table type possible_keys key key_len ref rows filtered Extra |
1 SIMPLE t1 index NULL ab 9 NULL 128 100.00 Using index |
Warnings:
|
Note 1003 select /*+ NO_INDEX(`t1`@`select#1` `PRIMARY`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` |
EXPLAIN EXTENDED SELECT/*+ NO_INDEX(t1) */ a FROM t1 GROUP BY a; |
id select_type table type possible_keys key key_len ref rows filtered Extra |
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 100.00 Using filesort |
Warnings:
|
Note 1003 select /*+ NO_INDEX(`t1`@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` |
EXPLAIN EXTENDED SELECT/*+ NO_INDEX(t1 a) */ a FROM t1 GROUP BY a; |
id select_type table type possible_keys key key_len ref rows filtered Extra |
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 100.00 Using filesort |
Warnings:
|
Warning 4222 Unresolved index name `t1`@`select#1` `a` for NO_INDEX hint |
Note 1003 select /*+ NO_INDEX(`t1`@`select#1` `a`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` |
Attachments
Issue Links
- is caused by
-
MDEV-35856 MySQL 8-style optimizer hints: milestone 2: index hints
-
- Closed
-