-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add some test cases for global index (#53630)
ref #45133
- Loading branch information
1 parent
2b68ccf
commit c79716e
Showing
14 changed files
with
439 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
set tidb_enable_global_index=true; | ||
drop table if exists p; | ||
create table p (id int, c int, unique index idx(id)) partition by range (c) ( | ||
partition p0 values less than (4), | ||
partition p1 values less than (7), | ||
partition p2 values less than (10)); | ||
insert into p values (1,3), (2,3), (3,4), (4,4), (5,6), (7,9), (8,9); | ||
explain format='brief' select count(*), max(id), min(id) from p use index(idx); | ||
id estRows task access object operator info | ||
HashAgg 1.00 root funcs:count(Column#9)->Column#4, funcs:max(Column#10)->Column#5, funcs:min(Column#11)->Column#6 | ||
└─IndexReader 1.00 root partition:all index:HashAgg | ||
└─HashAgg 1.00 cop[tikv] funcs:count(1)->Column#9, funcs:max(globalindex__aggregate.p.id)->Column#10, funcs:min(globalindex__aggregate.p.id)->Column#11 | ||
└─IndexFullScan 10000.00 cop[tikv] table:p, index:idx(id) keep order:false, stats:pseudo | ||
select count(*), max(id), min(id) from p use index(idx); | ||
count(*) max(id) min(id) | ||
7 8 1 | ||
explain format='brief' select count(*), max(id), min(id) from p partition(p0) use index(idx); | ||
id estRows task access object operator info | ||
HashAgg 1.00 root NULL funcs:count(Column#9)->Column#4, funcs:max(Column#10)->Column#5, funcs:min(Column#11)->Column#6 | ||
└─IndexReader 1.00 root partition:p0 index:HashAgg | ||
└─HashAgg 1.00 cop[tikv] NULL funcs:count(1)->Column#9, funcs:max(globalindex__aggregate.p.id)->Column#10, funcs:min(globalindex__aggregate.p.id)->Column#11 | ||
└─Selection 10000.00 cop[tikv] NULL in(_tidb_pid, pid0) | ||
└─IndexFullScan 10000.00 cop[tikv] table:p, index:idx(id) keep order:false, stats:pseudo | ||
select count(*), max(id), min(id) from p partition(p0) use index(idx); | ||
count(*) max(id) min(id) | ||
2 2 1 | ||
explain format='brief' select avg(id), max(id), min(id) from p use index(idx) group by c; | ||
id estRows task access object operator info | ||
HashAgg 8000.00 root group by:globalindex__aggregate.p.c, funcs:avg(Column#9, Column#10)->Column#4, funcs:max(Column#11)->Column#5, funcs:min(Column#12)->Column#6 | ||
└─IndexLookUp 8000.00 root partition:all | ||
├─IndexFullScan(Build) 10000.00 cop[tikv] table:p, index:idx(id) keep order:false, stats:pseudo | ||
└─HashAgg(Probe) 8000.00 cop[tikv] group by:globalindex__aggregate.p.c, funcs:count(globalindex__aggregate.p.id)->Column#9, funcs:sum(globalindex__aggregate.p.id)->Column#10, funcs:max(globalindex__aggregate.p.id)->Column#11, funcs:min(globalindex__aggregate.p.id)->Column#12 | ||
└─TableRowIDScan 10000.00 cop[tikv] table:p keep order:false, stats:pseudo | ||
select avg(id), max(id), min(id) from p use index(idx) group by c; | ||
avg(id) max(id) min(id) | ||
1.5000 2 1 | ||
3.5000 4 3 | ||
5.0000 5 5 | ||
7.5000 8 7 | ||
explain format='brief' select avg(id), max(id), min(id) from p partition(p0) use index(idx) group by c; | ||
id estRows task access object operator info | ||
HashAgg 8000.00 root NULL group by:globalindex__aggregate.p.c, funcs:avg(Column#9, Column#10)->Column#4, funcs:max(Column#11)->Column#5, funcs:min(Column#12)->Column#6 | ||
└─IndexLookUp 8000.00 root partition:p0 NULL | ||
├─Selection(Build) 10000.00 cop[tikv] NULL in(_tidb_pid, pid0) | ||
│ └─IndexFullScan 10000.00 cop[tikv] table:p, index:idx(id) keep order:false, stats:pseudo | ||
└─HashAgg(Probe) 8000.00 cop[tikv] NULL group by:globalindex__aggregate.p.c, funcs:count(globalindex__aggregate.p.id)->Column#9, funcs:sum(globalindex__aggregate.p.id)->Column#10, funcs:max(globalindex__aggregate.p.id)->Column#11, funcs:min(globalindex__aggregate.p.id)->Column#12 | ||
└─TableRowIDScan 10000.00 cop[tikv] table:p keep order:false, stats:pseudo | ||
select avg(id), max(id), min(id) from p partition(p0) use index(idx) group by c; | ||
avg(id) max(id) min(id) | ||
1.5000 2 1 |
39 changes: 39 additions & 0 deletions
39
tests/integrationtest/r/globalindex/expression_index.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
set tidb_enable_global_index=true; | ||
drop table if exists t; | ||
CREATE TABLE `t` ( | ||
`a` int(11) DEFAULT NULL, | ||
`b` char(11) DEFAULT NULL, | ||
UNIQUE KEY `idx` ((lower(`b`))) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`a`) PARTITIONS 5; | ||
insert into t values (1, 'a'), (2, 'b'), (3, 'C'), (4, 'd'), (5, 'x'); | ||
insert into t values (3, 'c'); | ||
Error 1062 (23000): Duplicate entry 'c' for key 't.idx' | ||
explain format='brief' select * from t use index(idx) where lower(b) = 'c'; | ||
id estRows task access object operator info | ||
Projection 1.00 root globalindex__expression_index.t.a, globalindex__expression_index.t.b | ||
└─Point_Get 1.00 root table:t, index:idx(lower(`b`)) | ||
select * from t use index(idx) where lower(b) = 'c'; | ||
a b | ||
3 C | ||
explain format='brief' select * from t use index(idx) where lower(b) > 'c' order by lower(b); | ||
id estRows task access object operator info | ||
Projection 3333.33 root globalindex__expression_index.t.a, globalindex__expression_index.t.b | ||
└─Projection 3333.33 root globalindex__expression_index.t.a, globalindex__expression_index.t.b, lower(globalindex__expression_index.t.b) | ||
└─IndexLookUp 3333.33 root partition:all | ||
├─IndexRangeScan(Build) 3333.33 cop[tikv] table:t, index:idx(lower(`b`)) range:("c",+inf], keep order:true, stats:pseudo | ||
└─TableRowIDScan(Probe) 3333.33 cop[tikv] table:t keep order:false, stats:pseudo | ||
select * from t use index(idx) where lower(b) > 'c' order by lower(b); | ||
a b | ||
4 d | ||
5 x | ||
explain format='brief' select * from t partition(p0) use index(idx) where lower(b) > 'c'; | ||
id estRows task access object operator info | ||
Projection 3333.33 root NULL globalindex__expression_index.t.a, globalindex__expression_index.t.b | ||
└─IndexLookUp 3333.33 root partition:p0 NULL | ||
├─Selection(Build) 3333.33 cop[tikv] NULL in(_tidb_pid, pid0) | ||
│ └─IndexRangeScan 3333.33 cop[tikv] table:t, index:idx(lower(`b`)) range:("c",+inf], keep order:false, stats:pseudo | ||
└─TableRowIDScan(Probe) 3333.33 cop[tikv] table:t keep order:false, stats:pseudo | ||
select * from t partition(p0) use index(idx) where lower(b) > 'c'; | ||
a b | ||
5 x |
Oops, something went wrong.