-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
affects-4.0This bug affects 4.0.x versions.This bug affects 4.0.x versions.affects-5.0This bug affects 5.0.x versions.This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.This bug affects the 5.4.x(LTS) versions.affects-6.0affects-6.1This bug affects the 6.1.x(LTS) versions.This bug affects the 6.1.x(LTS) versions.affects-6.2affects-6.3affects-6.4affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-6.6affects-7.0affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.sig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Enhancement
mysql> create table t1(a int, b int, c int, d int, index idx(a, b, c));
Query OK, 0 rows affected (0.06 sec)
mysql> explain select * from t1 where (a = 1 and b = 2 and c > 3) or (a = 4 and b = 5 and c > 6)
-> ;
+-------------------------------+---------+-----------+------------------------------+--------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------------+---------+-----------+------------------------------+--------------------------------------------------------------------------+
| IndexLookUp_10 | 0.67 | root | | |
| ├─IndexRangeScan_8(Build) | 0.67 | cop[tikv] | table:t1, index:idx(a, b, c) | range:(1 2 3,1 2 +inf], (4 5 6,4 5 +inf], keep order:false, stats:pseudo |
| └─TableRowIDScan_9(Probe) | 0.67 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+-------------------------------+---------+-----------+------------------------------+--------------------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> explain select * from t1 where ((a = 1 and b = 2 and c > 3) or (a = 4 and b = 5 and c > 6)) and d > 3;
+----------------------------+---------+-----------+------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------+---------+-----------+------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| IndexLookUp_12 | 0.22 | root | | |
| ├─Selection_10(Build) | 0.22 | cop[tikv] | | or(and(eq(test.t1.a, 1), and(eq(test.t1.b, 2), gt(test.t1.c, 3))), and(eq(test.t1.a, 4), and(eq(test.t1.b, 5), gt(test.t1.c, 6)))) |
| │ └─IndexRangeScan_8 | 20.00 | cop[tikv] | table:t1, index:idx(a, b, c) | range:[1,1], [4,4], keep order:false, stats:pseudo |
| └─Selection_11(Probe) | 0.22 | cop[tikv] | | gt(test.t1.d, 3) |
| └─TableRowIDScan_9 | 0.22 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+----------------------------+---------+-----------+------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
5 rows in set (0.00 sec)
The second query can also build (1 2 3,1 2 +inf], (4 5 6,4 5 +inf]
but currently we only build [1,1], [4,4]
.
Metadata
Metadata
Assignees
Labels
affects-4.0This bug affects 4.0.x versions.This bug affects 4.0.x versions.affects-5.0This bug affects 5.0.x versions.This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.This bug affects the 5.4.x(LTS) versions.affects-6.0affects-6.1This bug affects the 6.1.x(LTS) versions.This bug affects the 6.1.x(LTS) versions.affects-6.2affects-6.3affects-6.4affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-6.6affects-7.0affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.sig/plannerSIG: PlannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.