Files
tidb/tests/integrationtest/r/executor/index_merge_reader.result

563 lines
35 KiB
Plaintext

drop table if exists t1, t2;
create table t1(id int primary key, a int, b int, c int, d int);
create index t1a on t1(a);
create index t1b on t1(b);
insert into t1 values(1,1,1,1,1),(2,2,2,2,2),(3,3,3,3,3),(4,4,4,4,4),(5,5,5,5,5);
select /*+ use_index_merge(t1, primary, t1a) */ * from t1 where id < 2 or a > 4 order by id;
id a b c d
1 1 1 1 1
5 5 5 5 5
select /*+ use_index_merge(t1, primary, t1a) */ a from t1 where id < 2 or a > 4 order by a;
a
1
5
select /*+ use_index_merge(t1, primary, t1a) */ sum(a) from t1 where id < 2 or a > 4;
sum(a)
6
select /*+ use_index_merge(t1, t1a, t1b) */ * from t1 where a < 2 or b > 4 order by a;
id a b c d
1 1 1 1 1
5 5 5 5 5
select /*+ use_index_merge(t1, t1a, t1b) */ a from t1 where a < 2 or b > 4 order by a;
a
1
5
select /*+ use_index_merge(t1, t1a, t1b) */ sum(a) from t1 where a < 2 or b > 4;
sum(a)
6
drop table if exists t1, t2;
create table t1(id int primary key, a int, b int, c int, d int);
create index t1a on t1(a);
create index t1b on t1(b);
create table t2(id int primary key, a int);
create index t2a on t2(a);
insert into t1 values(1,1,1,1,1),(2,2,2,2,2),(3,3,3,3,3),(4,4,4,4,4),(5,5,5,5,5);
insert into t2 values(1,1),(5,5);
select /*+ use_index_merge(t1, t1a, t1b) */ sum(t1.a) from t1 join t2 on t1.id = t2.id where t1.a < 2 or t1.b > 4;
sum(t1.a)
6
select /*+ use_index_merge(t1, t1a, t1b) */ sum(t1.a) from t1 join t2 on t1.id = t2.id where t1.a < 2 or t1.b > 5;
sum(t1.a)
1
drop table if exists t0;
CREATE TABLE t0(c0 INT AS (1), c1 INT PRIMARY KEY);
INSERT INTO t0(c1) VALUES (0);
CREATE INDEX i0 ON t0(c0);
SELECT /*+ USE_INDEX_MERGE(t0, i0, PRIMARY)*/ t0.c0 FROM t0 WHERE t0.c1 OR t0.c0;
c0
1
SELECT t0.c0 FROM t0 WHERE t0.c1 OR t0.c0;
c0
1
drop table if exists t1;
create table t1(a int primary key, b int, c int, key(b), key(c));
INSERT INTO t1 VALUES (10, 10, 10), (11, 11, 11);
explain format='brief' select /*+ use_index_merge(t1) */ * from t1 where c=10 or (b=10 and a=10);
id estRows task access object operator info
IndexMerge 0.01 root type: union
├─IndexRangeScan(Build) 10.00 cop[tikv] table:t1, index:c(c) range:[10,10], keep order:false, stats:pseudo
├─TableRangeScan(Build) 1.00 cop[tikv] table:t1 range:[10,10], keep order:false, stats:pseudo
└─Selection(Probe) 0.01 cop[tikv] or(eq(executor__index_merge_reader.t1.c, 10), and(eq(executor__index_merge_reader.t1.b, 10), eq(executor__index_merge_reader.t1.a, 10)))
└─TableRowIDScan 11.00 cop[tikv] table:t1 keep order:false, stats:pseudo
select /*+ use_index_merge(t1) */ * from t1 where c=10 or (b=10 and a=10);
a b c
10 10 10
drop table if exists t1, t2, t3;
create table t1 (a int not null, b tinyint not null, index (a), index (b)) partition by range (a) (partition p0 values less than (10),partition p1 values less than (20),partition p2 values less than (30),partition p3 values less than (40),partition p4 values less than MAXVALUE);
insert into t1 values(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (10, 10), (11, 11), (12, 12), (13, 13), (14, 14), (15, 15), (20, 20), (21, 21), (22, 22), (23, 23), (24, 24), (25, 25), (30, 30), (31, 31), (32, 32), (33, 33), (34, 34), (35, 35), (36, 36), (40, 40), (50, 50), (80, 80), (90, 90), (100, 100);
create table t2 (a int not null, b bigint not null, index (a), index (b)) partition by hash(a) partitions 10;
insert into t2 values (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (11, 11), (12, 12), (13, 13), (14, 14), (15, 15), (16, 16), (17, 17), (18, 18), (19, 19), (20, 20), (21, 21), (22, 22), (23, 23);
select /*+ USE_INDEX_MERGE(t1, a, b) */ * from t1 partition (p0) join t2 partition (p1) on t1.a = t2.a where t1.a < 40 or t1.b < 30;
a b a b
1 1 1 1
drop table if exists t;
set @@tidb_enable_index_merge = 1;
create table t (a int, b int, c int, primary key(a), key(b));
explain format='brief' select /*+ inl_join(t2) */ * from t t1 join t t2 on t1.a = t2.a and t1.c = t2.c where t2.a = 1 or t2.b = 1;
id estRows task access object operator info
Projection 13.74 root executor__index_merge_reader.t.a, executor__index_merge_reader.t.b, executor__index_merge_reader.t.c, executor__index_merge_reader.t.a, executor__index_merge_reader.t.b, executor__index_merge_reader.t.c
└─IndexJoin 13.74 root inner join, inner:TableReader, outer key:executor__index_merge_reader.t.a, inner key:executor__index_merge_reader.t.a, equal cond:eq(executor__index_merge_reader.t.a, executor__index_merge_reader.t.a), eq(executor__index_merge_reader.t.c, executor__index_merge_reader.t.c), other cond:or(eq(executor__index_merge_reader.t.a, 1), eq(executor__index_merge_reader.t.b, 1))
├─TableReader(Build) 9990.00 root data:Selection
│ └─Selection 9990.00 cop[tikv] not(isnull(executor__index_merge_reader.t.c))
│ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
└─TableReader(Probe) 10.98 root data:Selection
└─Selection 10.98 cop[tikv] not(isnull(executor__index_merge_reader.t.c)), or(eq(executor__index_merge_reader.t.a, 1), eq(executor__index_merge_reader.t.b, 1))
└─TableRangeScan 9990.00 cop[tikv] table:t2 range: decided by [executor__index_merge_reader.t.a], keep order:false, stats:pseudo
set @@tidb_enable_index_merge = default;
drop table if exists t1;
create table t1(c1 int, c2 int, c3 int, pk int, key(c1), key(c2), key(c3), primary key(pk));
begin;
explain select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and c3 < 10;
id estRows task access object operator info
IndexMerge_9 1841.86 root type: union
├─IndexRangeScan_5(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_6(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_8(Probe) 1841.86 cop[tikv] lt(executor__index_merge_reader.t1.c3, 10)
└─TableRowIDScan_7 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo
explain select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < 10) and c3 < 10;
id estRows task access object operator info
IndexMerge_9 1106.67 root type: union
├─TableRangeScan_5(Build) 3333.33 cop[tikv] table:t1 range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_6(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_8(Probe) 1106.67 cop[tikv] lt(executor__index_merge_reader.t1.c3, 10)
└─TableRowIDScan_7 3330.01 cop[tikv] table:t1 keep order:false, stats:pseudo
explain select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where c1 < 10 and c2 < 10 and c3 < 10;
id estRows task access object operator info
IndexMerge_9 367.05 root type: intersection
├─IndexRangeScan_5(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_6(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_7(Build) 3323.33 cop[tikv] table:t1, index:c3(c3) range:[-inf,10), keep order:false, stats:pseudo
└─TableRowIDScan_8(Probe) 367.05 cop[tikv] table:t1 keep order:false, stats:pseudo
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < -1 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
insert into t1 values(1, 1, 1, 1);
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
update t1 set c3 = 100 where c3 = 1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
1 1 100 1
delete from t1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < -1 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < -1) and c3 < 10;
c1 c2 c3 pk
insert into t1 values(1, 1, 1, 1);
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
update t1 set c3 = 100 where c3 = 1;
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
1 1 100 1
delete from t1;
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
commit;
drop table if exists t1;
create table t1(c1 int, c2 int, c3 int, pk int, key(c1), key(c2), key(c3), primary key(pk));
set tx_isolation = 'READ-COMMITTED';
begin;
explain select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and c3 < 10;
id estRows task access object operator info
IndexMerge_9 1841.86 root type: union
├─IndexRangeScan_5(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_6(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_8(Probe) 1841.86 cop[tikv] lt(executor__index_merge_reader.t1.c3, 10)
└─TableRowIDScan_7 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo
explain select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < 10) and c3 < 10;
id estRows task access object operator info
IndexMerge_9 1106.67 root type: union
├─TableRangeScan_5(Build) 3333.33 cop[tikv] table:t1 range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_6(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_8(Probe) 1106.67 cop[tikv] lt(executor__index_merge_reader.t1.c3, 10)
└─TableRowIDScan_7 3330.01 cop[tikv] table:t1 keep order:false, stats:pseudo
explain select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where c1 < 10 and c2 < 10 and c3 < 10;
id estRows task access object operator info
IndexMerge_9 367.05 root type: intersection
├─IndexRangeScan_5(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_6(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_7(Build) 3323.33 cop[tikv] table:t1, index:c3(c3) range:[-inf,10), keep order:false, stats:pseudo
└─TableRowIDScan_8(Probe) 367.05 cop[tikv] table:t1 keep order:false, stats:pseudo
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < -1 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
insert into t1 values(1, 1, 1, 1);
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
update t1 set c3 = 100 where c3 = 1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
1 1 100 1
delete from t1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c1, c2, c3) */ * from t1 where (c1 < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < -1 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < -1) and c3 < 10;
c1 c2 c3 pk
insert into t1 values(1, 1, 1, 1);
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < 10) and c3 < 10;
c1 c2 c3 pk
1 1 1 1
update t1 set c3 = 100 where c3 = 1;
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
1 1 100 1
delete from t1;
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 10) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < -1) and c3 < 10;
c1 c2 c3 pk
select /*+ use_index_merge(t1, c2, c3, primary) */ * from t1 where (pk < 10 and c2 < 10) and c3 > 10;
c1 c2 c3 pk
commit;
set tx_isolation = 'REPEATABLE-READ';
drop table if exists t1;
create table t1(c1 int, c2 int, c3 int, pk int, key(c1), key(c2), key(c3), primary key(pk));
begin;
explain select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and c3 < 10 for update;
id estRows task access object operator info
SelectLock_6 1841.86 root for update 0
└─IndexMerge_11 1841.86 root type: union
├─IndexRangeScan_7(Build) 3323.33 cop[tikv] table:t1, index:c1(c1) range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_8(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_10(Probe) 1841.86 cop[tikv] lt(executor__index_merge_reader.t1.c3, 10)
└─TableRowIDScan_9 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo
explain select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < 10) and c3 < 10 for update;
id estRows task access object operator info
SelectLock_6 1106.67 root for update 0
└─IndexMerge_11 1106.67 root type: union
├─TableRangeScan_7(Build) 3333.33 cop[tikv] table:t1 range:[-inf,10), keep order:false, stats:pseudo
├─IndexRangeScan_8(Build) 3323.33 cop[tikv] table:t1, index:c2(c2) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_10(Probe) 1106.67 cop[tikv] lt(executor__index_merge_reader.t1.c3, 10)
└─TableRowIDScan_9 3330.01 cop[tikv] table:t1 keep order:false, stats:pseudo
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
insert into t1 values(1, 1, 1, 1);
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
1 1 1 1
update t1 set c3 = 100 where c3 = 1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
delete from t1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
insert into t1 values(1, 1, 1, 1);
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
1 1 1 1
update t1 set c3 = 100 where c3 = 1;
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
delete from t1;
select /*+ use_index_merge(t1) */ * from t1 where (pk < 10 or c2 < 10) and c3 < 10 for update;
c1 c2 c3 pk
commit;
drop table if exists t1;
create table t1(c1 int, c2 int, c3 int, pk int, part int, key(c1), key(c2), key(c3), primary key(pk, part))
partition by range(part) (
partition p0 values less than (10),
partition p1 values less than (20),
partition p2 values less than (maxvalue));
begin;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 20 or c2 < 20) and c3 < 20;
c1 c2 c3 pk part
insert into t1 values(1, 1, 1, 1, 1);
insert into t1 values(11, 11, 11, 11, 11);
insert into t1 values(21, 21, 21, 21, 21);
insert into t1 values(31, 31, 31, 31, 31);
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 20) and c3 < 20;
c1 c2 c3 pk part
1 1 1 1 1
11 11 11 11 11
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 20 or c2 < -1) and c3 < 20;
c1 c2 c3 pk part
1 1 1 1 1
11 11 11 11 11
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 20) and c3 < 20;
c1 c2 c3 pk part
1 1 1 1 1
11 11 11 11 11
select /*+ use_index_merge(t1) */ * from t1 where (pk < 20 or c2 < -1) and c3 < 20;
c1 c2 c3 pk part
1 1 1 1 1
11 11 11 11 11
update t1 set c3 = 100 where c3 = 1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 20) and c3 < 20;
c1 c2 c3 pk part
11 11 11 11 11
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 20 or c2 < -1) and c3 < 20;
c1 c2 c3 pk part
11 11 11 11 11
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 20) and c3 < 20;
c1 c2 c3 pk part
11 11 11 11 11
select /*+ use_index_merge(t1) */ * from t1 where (pk < 20 or c2 < -1) and c3 < 20;
c1 c2 c3 pk part
11 11 11 11 11
delete from t1;
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c2 < 20) and c3 < 20;
c1 c2 c3 pk part
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 20 or c2 < -1) and c3 < 20;
c1 c2 c3 pk part
select /*+ use_index_merge(t1) */ * from t1 where (pk < -1 or c2 < 20) and c3 < 20;
c1 c2 c3 pk part
select /*+ use_index_merge(t1) */ * from t1 where (pk < 20 or c2 < -1) and c3 < 20;
c1 c2 c3 pk part
commit;
set tx_isolation = default;
drop table if exists t1;
create table t1 (col_30 decimal default 0 ,
col_31 char(99) collate utf8_bin default 'sVgzHblmYYtEjVg' not null ,
col_37 int unsigned default 377206828 ,
primary key idx_16 ( col_37 ) , key idx_19 ( col_31) ) collate utf8mb4_general_ci ;
begin;
insert ignore into t1 values (388021, '', 416235653);
select /*+ use_index_merge( t1 ) */ 1 from t1 where ( t1.col_31 in ( 'OiOXzpCs' , 'oaVv' ) or t1.col_37 <= 4059907010 ) and t1.col_30 ;
1
1
commit;
drop table if exists tbl_3;
create table tbl_3 ( col_30 decimal , col_31 char(99) , col_32 smallint ,
col_33 tinyint unsigned not null , col_34 char(209) ,
col_35 char(110) , col_36 int unsigned , col_37 int unsigned ,
col_38 decimal(50,15) not null , col_39 char(104),
primary key ( col_37 ) , unique key ( col_33,col_30,col_36,col_39 ) ,
unique key ( col_32,col_35 ) , key ( col_31,col_38 ) ,
key ( col_31,col_33,col_32,col_35,col_36 ) ,
unique key ( col_38,col_34,col_33,col_31,col_30,col_36,col_35,col_37,col_39 ) ,
unique key ( col_39,col_32 ) , unique key ( col_30,col_35,col_31,col_38 ) ,
key ( col_38,col_32,col_33 ) );
begin;
insert ignore into tbl_3 values ( 71,'Fipc',-6676,30,'','FgfK',2464927398,4084082400,5602.5868,'' );
select /*+ use_index_merge( tbl_3 ) */ 1 from tbl_3 where ( tbl_3.col_37 not in ( 1626615245 , 2433569159 ) or tbl_3.col_38 = 0.06 ) ;
1
1
commit;
drop table if exists t1;
create table t1(c1 int, c2 int, c3 int, c4 int, primary key(c1, c2) /*T![clustered_index] CLUSTERED */, key(c3));
begin;
insert into t1 values(1, 1, 1, 1);
explain select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c3 < 10) and c4 < 10;
id estRows task access object operator info
UnionScan_6 1841.86 root lt(executor__index_merge_reader.t1.c4, 10), or(lt(executor__index_merge_reader.t1.c1, -1), lt(executor__index_merge_reader.t1.c3, 10))
└─IndexMerge_11 1841.86 root type: union
├─TableRangeScan_7(Build) 3323.33 cop[tikv] table:t1 range:[-inf,-1), keep order:false, stats:pseudo
├─IndexRangeScan_8(Build) 3323.33 cop[tikv] table:t1, index:c3(c3) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_10(Probe) 1841.86 cop[tikv] lt(executor__index_merge_reader.t1.c4, 10)
└─TableRowIDScan_9 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c3 < 10) and c4 < 10;
c1 c2 c3 c4
1 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 10 or c3 < -1) and c4 < 10;
c1 c2 c3 c4
1 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (c1 < -1 or c3 < -1) and c4 < 10;
c1 c2 c3 c4
commit;
drop table if exists t1;
create table t1(c1 varchar(100), c2 int, c3 int, c4 int, primary key(c1) /*T![clustered_index] CLUSTERED */, key(c3));
begin;
insert into t1 values('b', 1, 1, 1);
explain select /*+ use_index_merge(t1) */ * from t1 where (c1 < 'a' or c3 < 10) and c4 < 10;
id estRows task access object operator info
UnionScan_6 1841.86 root lt(executor__index_merge_reader.t1.c4, 10), or(lt(executor__index_merge_reader.t1.c1, "a"), lt(executor__index_merge_reader.t1.c3, 10))
└─IndexMerge_11 1841.86 root type: union
├─TableRangeScan_7(Build) 3323.33 cop[tikv] table:t1 range:[-inf,"a"), keep order:false, stats:pseudo
├─IndexRangeScan_8(Build) 3323.33 cop[tikv] table:t1, index:c3(c3) range:[-inf,10), keep order:false, stats:pseudo
└─Selection_10(Probe) 1841.86 cop[tikv] lt(executor__index_merge_reader.t1.c4, 10)
└─TableRowIDScan_9 5542.21 cop[tikv] table:t1 keep order:false, stats:pseudo
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 'a' or c3 < 10) and c4 < 10;
c1 c2 c3 c4
b 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (c1 <= 'b' or c3 < -1) and c4 < 10;
c1 c2 c3 c4
b 1 1 1
select /*+ use_index_merge(t1) */ * from t1 where (c1 < 'a' or c3 < -1) and c4 < 10;
c1 c2 c3 c4
commit;
DROP TABLE IF EXISTS tab2;
CREATE TABLE tab2(pk INTEGER PRIMARY KEY, col0 INTEGER, col1 FLOAT, col2 TEXT, col3 INTEGER, col4 FLOAT, col5 TEXT);
CREATE INDEX idx_tab2_0 ON tab2 (col0 DESC,col3 DESC);
CREATE UNIQUE INDEX idx_tab2_3 ON tab2 (col4,col0 DESC);
CREATE INDEX idx_tab2_4 ON tab2 (col3,col1 DESC);
INSERT INTO tab2 VALUES(0,146,632.63,'shwwd',703,412.47,'xsppr');
INSERT INTO tab2 VALUES(1,81,536.29,'trhdh',49,726.3,'chuxv');
INSERT INTO tab2 VALUES(2,311,541.72,'txrvb',493,581.92,'xtrra');
INSERT INTO tab2 VALUES(3,669,293.27,'vcyum',862,415.14,'nbutk');
INSERT INTO tab2 VALUES(4,681,49.46,'odzhp',106,324.65,'deudp');
INSERT INTO tab2 VALUES(5,319,769.65,'aeqln',855,197.9,'apipa');
INSERT INTO tab2 VALUES(6,610,302.62,'bixap',184,840.31,'vggit');
INSERT INTO tab2 VALUES(7,253,453.21,'gjccm',107,104.5,'lvunv');
SPLIT TABLE tab2 BY (5);
TOTAL_SPLIT_REGION SCATTER_FINISH_RATIO
1 1
SELECT /*+ use_index_merge(tab2) */ pk FROM tab2 WHERE (col4 > 565.89 OR col0 > 68 ) and col0 > 10 order by 1;
pk
0
1
2
3
4
5
6
7
drop table if exists t;
create table t(a int, b int, c int, index idx(a, c), index idx2(b, c));
insert into t values(1, 1, 1), (2, 2, 2);
explain format='brief' select /*+ USE_INDEX_MERGE(t, idx, idx2) */ * from t where a = 1 or b = 1 limit 1;
id estRows task access object operator info
IndexMerge 1.00 root type: union, limit embedded(offset:0, count:1)
├─Limit(Build) 0.50 cop[tikv] offset:0, count:1
│ └─IndexRangeScan 0.50 cop[tikv] table:t, index:idx(a, c) range:[1,1], keep order:false, stats:pseudo
├─Limit(Build) 0.50 cop[tikv] offset:0, count:1
│ └─IndexRangeScan 0.50 cop[tikv] table:t, index:idx2(b, c) range:[1,1], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 1.00 cop[tikv] table:t keep order:false, stats:pseudo
select /*+ USE_INDEX_MERGE(t, idx, idx2) */ * from t where a = 1 or b = 1 limit 1;
a b c
1 1 1
drop table if exists t;
create table t(a int, b int, c int, index idx1(a, c), index idx2(b, c));
insert into t values(1, 1, 1), (1, 2, -1), (2, 1, -2);
begin;
insert into t values(1, 1, -3);
explain select /*+ USE_INDEX_MERGE(t, idx1, idx2) */ * from t where a = 1 or b = 1 order by c limit 2;
id estRows task access object operator info
Projection_8 2.00 root executor__index_merge_reader.t.a, executor__index_merge_reader.t.b, executor__index_merge_reader.t.c
└─Limit_15 2.00 root offset:0, count:2
└─UnionScan_21 2.00 root or(eq(executor__index_merge_reader.t.a, 1), eq(executor__index_merge_reader.t.b, 1))
└─IndexMerge_25 2.00 root type: union
├─IndexRangeScan_22(Build) 1.00 cop[tikv] table:t, index:idx1(a, c) range:[1,1], keep order:true, stats:pseudo
├─IndexRangeScan_23(Build) 1.00 cop[tikv] table:t, index:idx2(b, c) range:[1,1], keep order:true, stats:pseudo
└─TableRowIDScan_24(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo
select /*+ USE_INDEX_MERGE(t, idx1, idx2) */ * from t where a = 1 or b = 1 order by c limit 2;
a b c
1 1 -3
2 1 -2
rollback;
begin;
insert into t values(1, 2, 4);
explain select /*+ USE_INDEX_MERGE(t, idx1, idx2) */ * from t where a = 1 or b = 1 order by c desc limit 2;
id estRows task access object operator info
Projection_8 2.00 root executor__index_merge_reader.t.a, executor__index_merge_reader.t.b, executor__index_merge_reader.t.c
└─Limit_15 2.00 root offset:0, count:2
└─UnionScan_21 2.00 root or(eq(executor__index_merge_reader.t.a, 1), eq(executor__index_merge_reader.t.b, 1))
└─IndexMerge_25 2.00 root type: union
├─IndexRangeScan_22(Build) 1.00 cop[tikv] table:t, index:idx1(a, c) range:[1,1], keep order:true, desc, stats:pseudo
├─IndexRangeScan_23(Build) 1.00 cop[tikv] table:t, index:idx2(b, c) range:[1,1], keep order:true, desc, stats:pseudo
└─TableRowIDScan_24(Probe) 2.00 cop[tikv] table:t keep order:false, stats:pseudo
select /*+ USE_INDEX_MERGE(t, idx1, idx2) */ * from t where a = 1 or b = 1 order by c desc limit 2;
a b c
1 2 4
1 1 1
rollback;
drop table if exists t1;
create table t1(pk varchar(100) primary key, c1 int, c2 int, index idx1(c1), index idx2(c2));
insert into t1 values('TXwuGSfZfrgVbTksgvQBilqiUXlNEXzyXNqWRTCidzXFbrkpGFJalRMdVGQOAOojditwludthMcitNqNtvirGAudSNBtdIkpJIHQ', 1, 1), ('LSiKhgTNnuyjdBtuKKuRgzrcxbHrIlfxSkEuooaPYwfOBVQfNYAyatHiWvmUWRUvBLvXmpqAJUWRXXHFCLCjuJqFbVxQdUxqRuqW', 1, 1), ('qCOSFbvtmansHENQaAQbnyYOwCTPctlejpbpueHbtzskmPOazrMWdcMLaYjyfxYQUgDDjCnAnnExepNqwYIzHVjNVndlOzFaAOcf', 1, 1), ('qBqdtPyXIqLKynGNHnRlrufuUCZPqhxUYEqIrYERnQdqXRjVWcoYclxYXoqdpQboKydzhOHOWBwtmcXzGwCWQVdbpozvIaXxiBQj', 1, 1), ('TXZlGHnXOiSWGyRafAqworFmxuadHRTHcYyzLqZMzIMGUUBQmgiIJKQOqbHhoPEKbYBgfPDZJwwqgnCbMxZKaZfvGyVRRUOgRhoq', 1, 1), ('SwFEtKDfPDQpsyxTdTruPyNDLvEOLRdQtSttxJmgBuZiVKsflHCDZaGvkLHMqhHqLayfbZFrxUHzWHgfoPFCWCdCHScabWRNCHCL', 1, 1), ('BuZhnsTMGNtMJtrjjdMMrguutSpiLnZNCdgiNkWDPymzIymcujjBtsnKCAVRSErvbzPaOwLTTPWkGmbXltqOJXmkXnSWWlWaaBqe', 1, 1), ('LuJCpJrLUwDJutwBDtGEsGduteBWPHeGLVhmVJYVrmjunKNuplEeWDCMIAxHPoiRmdPnXneQEQWRvJkPBoXOPaGZhhFLFgGraLmH', 1, 1), ('JKJwMlPmymduJWOmKLFBmZyCFrcUvKcGQkzJmzGjuFoZweyCBptswEPHTkaIhWEEBMWzNBawtfYKKAugBNlxcwmpJSfuIAUSIxeG', 1, 1), ('IqQbehKwleoSUnwxrVLKSbzRqlEFfkwQtRtIfaVpEGfESyGjDJeAOWQPRYVQYvlPNPROQEraCqwQTzanPSrsnUvEXHSxcYjUJvzk', 1, 1), ('zNHmiBGCLUUEDgMAeIGuTgNJFPBtePpxcQrQlgnRlvosJfeYbhRfJdfMwXIRlXxVoOowhEvPhMQPlplzkUfjjmzdJKwGATvfDAiT', 1, 1), ('OjQvpfdsHSdZUAmGfmtQaYKYONAFHGNLeLKRYECqshxygiOzfKkqRwSYGgClqqnpHqPMZpqsjIYSalziqSfMbbtmmzxkOVgglVOh', 1, 1), ('dXXZaWDwdfhjIysLTNMSfwvoEBJhWOVpJnfXFofWSWMfMbUlRgAkobxoCxXPXNUWzAQczbQclQpvIvvATHHcQgdXUvwSTHqLXZny', 1, 1), ('haPqYVwFNUkedfIKPOPyUxIvbSkaUbsEWNvnDtXZsQQqafIhDXlajYpuXOSYiOwGJYAMVLUvXfwOIuyHKElzJHpOUdCiQiXRHubI', 1, 1), ('nQzOwSsVBjCpehVVmLeyYwyVEwYGAfkhCtkkaKyiXzYCRPRVZpNVnOXGbuWrQEgTuPEPFPApUaYLdCtyBEQulFEwyHlORrMfIJxr', 1, 1), ('ksGDopwNPvpjeCtAMaTrznDSgCLpRDQoCdsahWSjwumVEJITbNBPAAtkoxHuwmNQsryoILqCPBPiUSxAWjnFEdtxDIgEtqDiFvpO', 1, 1), ('AdWEZYzxCMhfcZseNVmNQpyqJrVKcKaZpKKcwZXfDPeIBMzkLzpJpOenidMBtBPBIbaiqfpSxBnGtRHAksBOgpigQTVomZzJhCFb', 1, 1), ('bVMNkLOAuRHqnCtGvVPLvmVSKihYFotmHTjObiAIARHawZTruAabGpFxeYxYTTFRxteFYyBfkBfiSEIFvOPquDnlVRNUUubssEMz', 1, 1), ('kXmcjqMYzGxvHBRRCovSTWavDnVajKLlxguJgniJeNkWQUxjHjYjBsveLfojybWkbqHBVzrOoqgXFrDnnRJPcybmnuAEUTPUoIjO', 1, 1), ('rVXzZDKudOpWCBuRCoQCpukHxenZnsaptDeJCCFzxMVvNucFwLKIiSceLsqUHHQuEfAIygjQCCkIbfInGthSnoLdNGWbsLDsxnrY', 1, 1);
explain format='brief' select /*+ use_index_merge(t1, primary, idx1, idx2) */ c1 from t1 where c1 < 1024 and c2 < 1024;
id estRows task access object operator info
Projection 1104.45 root executor__index_merge_reader.t1.c1
└─IndexMerge 1104.45 root type: intersection
├─IndexRangeScan(Build) 3323.33 cop[tikv] table:t1, index:idx1(c1) range:[-inf,1024), keep order:false, stats:pseudo
├─IndexRangeScan(Build) 3323.33 cop[tikv] table:t1, index:idx2(c2) range:[-inf,1024), keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 1104.45 cop[tikv] table:t1 keep order:false, stats:pseudo
set global tidb_mem_oom_action='CANCEL';
set @@tidb_mem_quota_query = 4000;
select /*+ use_index_merge(t1, primary, idx1, idx2) */ c1 from t1 where c1 < 1024 and c2 < 1024;
Error 8175 (HY000): Your query has been cancelled due to exceeding the allowed memory limit for a single SQL query. Please try narrowing your query scope or increase the tidb_mem_quota_query limit and try again.[conn=<num>]
set global tidb_mem_oom_action = DEFAULT;
set @@tidb_mem_quota_query = default;
drop table if exists t;
CREATE TABLE `t` (`a` mediumint(9) NOT NULL,`b` year(4) NOT NULL,`c` varbinary(62) NOT NULL,`d` text COLLATE utf8mb4_unicode_ci NOT NULL,`e` tinyint(4) NOT NULL DEFAULT '115',`f` smallint(6) DEFAULT '2675',`g` date DEFAULT '1981-09-17',`h` mediumint(8) unsigned NOT NULL,`i` varchar(384) CHARACTER SET gbk COLLATE gbk_bin DEFAULT NULL,UNIQUE KEY `idx_23` (`h`,`f`),PRIMARY KEY (`h`,`a`) /*T![clustered_index] CLUSTERED */,UNIQUE KEY `idx_25` (`h`,`i`(5),`e`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin PARTITION BY HASH (`h`) PARTITIONS 1;
INSERT INTO `t` VALUES (2065948,1999,_binary '8jxN','rf',-54,-5656,'1987-07-03',259254,'7me坨'),(-8248164,2024,_binary 'zA5A','s)DAkX3',-93,-12983,'2027-12-18',299573,'LUf咲'),(-6131509,2023,_binary 'xdex#Y2','1th%h',-51,19149,'2013-10-28',428279,'矷莒X'),(7545837,1998,_binary 'PCVO','&(lJw6',30,4093,'1987-07-03',736235,'腏@TOIJ'),(-7449472,2029,_binary 'B7&jrl','EjbFfX!',80,-7590,'2011-11-03',765580,'堮ZQF_'),(-7176200,1988,_binary 'tiPglv7mX_#','CnCtNb',-25,NULL,'1987-07-03',842956,'Gq羣嗳殓'),(-115168,2036,_binary 'BqmX$-4It','!8#dvH',82,18787,'1991-09-20',921706,'椉2庘v'),(6665100,1987,_binary '4IJgk0fr4','(D',-73,28628,'1987-07-03',1149668,'摔玝S渉'),(-4065661,2021,_binary '8G%','xDO39xw#',-107,17356,'1970-12-20',1316239,'+0c35掬-阗'),(7622462,1990,_binary '&o+)s)D0','kjoS9Dzld',84,688,'1987-07-03',1403663,'$H鍿_M~'),(5269354,2018,_binary 'wq9hC8','s8XPrN+',-2,-31272,'2008-05-26',1534517,'y椁n躁Q'),(2065948,1982,_binary '8jxNjbksV','g$+i4dg',11,19800,'1987-07-03',1591457,'z^+H~薼A'),(4076971,2024,_binary '&!RrsH','7Mpvk',-63,-632,'2032-10-28',1611011,'鬰+EXmx'),(3522062,1981,_binary ')nq#!UiHKk8','j~wFe77ai',50,6951,'1987-07-03',1716854,'J'),(7859777,2012,_binary 'PBA5xgJ&G&','UM7o!u',18,-5978,'1987-07-03',1967012,'e)浢L獹'),(2065948,2028,_binary '8jxNjbk','JmsEki9t4',51,12002,'2017-12-23',1981288,'mp氏襚');
explain format='brief' SELECT /*+ AGG_TO_COP() STREAM_AGG()*/ (NOT (`t`.`i`>=_UTF8MB4'j筧8') OR NOT (`t`.`i`=_UTF8MB4'暈lH忧ll6')) IS TRUE,MAX(`t`.`e`) AS `r0`,QUOTE(`t`.`i`) AS `r1` FROM `t` WHERE `t`.`h`>240817 OR `t`.`i` BETWEEN _UTF8MB4'WVz' AND _UTF8MB4'G#駧褉ZC領*lov' GROUP BY `t`.`i`;
id estRows task access object operator info
Projection 2666.67 root istrue(or(not(ge(executor__index_merge_reader.t.i, j筧8)), not(eq(executor__index_merge_reader.t.i, 暈lH忧ll6))))->Column#11, Column#10, quote(executor__index_merge_reader.t.i)->Column#12
└─StreamAgg 2666.67 root group by:executor__index_merge_reader.t.i, funcs:max(executor__index_merge_reader.t.e)->Column#10, funcs:firstrow(executor__index_merge_reader.t.i)->executor__index_merge_reader.t.i
└─Sort 3333.33 root executor__index_merge_reader.t.i
└─IndexMerge 3333.33 root partition:all type: union
├─IndexFullScan(Build) 0.00 cop[tikv] table:t, index:idx_25(h, i, e) keep order:false, stats:pseudo
├─TableRangeScan(Build) 3333.33 cop[tikv] table:t range:(240817,+inf], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 3333.33 cop[tikv] table:t keep order:false, stats:pseudo
select count(*) from (SELECT /*+ AGG_TO_COP() STREAM_AGG()*/ (NOT (`t`.`i`>=_UTF8MB4'j筧8') OR NOT (`t`.`i`=_UTF8MB4'暈lH忧ll6')) IS TRUE,MAX(`t`.`e`) AS `r0`,QUOTE(`t`.`i`) AS `r1` FROM `t` WHERE `t`.`h`>240817 OR `t`.`i` BETWEEN _UTF8MB4'WVz' AND _UTF8MB4'G#駧褉ZC領*lov' GROUP BY `t`.`i`) derived;
count(*)
16
explain format='brief' SELECT /*+ AGG_TO_COP() */ (NOT (`t`.`i`>=_UTF8MB4'j筧8') OR NOT (`t`.`i`=_UTF8MB4'暈lH忧ll6')) IS TRUE,MAX(`t`.`e`) AS `r0`,QUOTE(`t`.`i`) AS `r1` FROM `t` WHERE `t`.`h`>240817 OR `t`.`i` BETWEEN _UTF8MB4'WVz' AND _UTF8MB4'G#駧褉ZC領*lov' GROUP BY `t`.`i`;
id estRows task access object operator info
Projection 2666.67 root istrue(or(not(ge(executor__index_merge_reader.t.i, j筧8)), not(eq(executor__index_merge_reader.t.i, 暈lH忧ll6))))->Column#11, Column#10, quote(executor__index_merge_reader.t.i)->Column#12
└─HashAgg 2666.67 root group by:executor__index_merge_reader.t.i, funcs:max(executor__index_merge_reader.t.e)->Column#10, funcs:firstrow(executor__index_merge_reader.t.i)->executor__index_merge_reader.t.i
└─IndexMerge 3333.33 root partition:all type: union
├─IndexFullScan(Build) 0.00 cop[tikv] table:t, index:idx_25(h, i, e) keep order:false, stats:pseudo
├─TableRangeScan(Build) 3333.33 cop[tikv] table:t range:(240817,+inf], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 3333.33 cop[tikv] table:t keep order:false, stats:pseudo
select count(*) from (SELECT /*+ AGG_TO_COP() */ (NOT (`t`.`i`>=_UTF8MB4'j筧8') OR NOT (`t`.`i`=_UTF8MB4'暈lH忧ll6')) IS TRUE,MAX(`t`.`e`) AS `r0`,QUOTE(`t`.`i`) AS `r1` FROM `t` WHERE `t`.`h`>240817 OR `t`.`i` BETWEEN _UTF8MB4'WVz' AND _UTF8MB4'G#駧褉ZC領*lov' GROUP BY `t`.`i`) derived;
count(*)
16
drop table if exists t;
create table t(a int, b int, c int, index(b, a), index(c, a));
select * from t use index(b, c) where b=2 or c=3 order by a limit 10000000000000000;
a b c