Skip to content

planner: NullEQ cannot be used for composite indexes #29650

@qw4990

Description

@qw4990

Enhancement

mysql> show create table t;
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL,
  KEY `a` (`a`,`b`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> explain select * from t where a<=>null and b=1;
+--------------------------+---------+-----------+------------------------+---------------------------------------------------+
| id                       | estRows | task      | access object          | operator info                                     |
+--------------------------+---------+-----------+------------------------+---------------------------------------------------+
| IndexReader_7            | 0.01    | root      |                        | index:Selection_6                                 |
| └─Selection_6            | 0.01    | cop[tikv] |                        | eq(test.t.b, 1)                                   |
|   └─IndexRangeScan_5     | 10.00   | cop[tikv] | table:t, index:a(a, b) | range:[NULL,NULL], keep order:false, stats:pseudo |
+--------------------------+---------+-----------+------------------------+---------------------------------------------------+
3 rows in set (0.00 sec)

The range should be [NULL 1, NULL 1].

Metadata

Metadata

Assignees

Labels

sig/plannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions