-
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.
distsql: support global index in
memIndexLookUpReader
(#52240)
close #52132
- Loading branch information
1 parent
27e470a
commit b4c8b52
Showing
8 changed files
with
166 additions
and
18 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 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 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
47 changes: 47 additions & 0 deletions
47
tests/integrationtest/r/globalindex/mem_index_lookup.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,47 @@ | ||
set tidb_enable_global_index=true; | ||
# IntHandle | ||
drop table if exists t; | ||
CREATE TABLE `t` ( | ||
`a` int(11) DEFAULT NULL, | ||
`b` int(11) DEFAULT NULL, | ||
UNIQUE KEY `idx1` (`b`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`a`) PARTITIONS 5; | ||
begin; | ||
insert into t values (1, 2), (2, 3), (3, 4), (4, 5), (5, 1); | ||
explain select * from t use index(idx1) where b > 2; | ||
id estRows task access object operator info | ||
Projection_5 3333.33 root globalindex__mem_index_lookup.t.a, globalindex__mem_index_lookup.t.b | ||
└─UnionScan_6 3333.33 root gt(globalindex__mem_index_lookup.t.b, 2) | ||
└─IndexLookUp_9 3333.33 root partition:all | ||
├─IndexRangeScan_7(Build) 3333.33 cop[tikv] table:t, index:idx1(b) range:(2,+inf], keep order:false, stats:pseudo | ||
└─TableRowIDScan_8(Probe) 3333.33 cop[tikv] table:t keep order:false, stats:pseudo | ||
select * from t use index(idx1) where b > 2; | ||
a b | ||
2 3 | ||
3 4 | ||
4 5 | ||
rollback; | ||
# CommonHandle | ||
drop table if exists t; | ||
CREATE TABLE `t` ( | ||
`a` year(4) primary key, | ||
`b` int(11) DEFAULT NULL, | ||
UNIQUE KEY `idx1` (`b`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`a`) PARTITIONS 5; | ||
begin; | ||
insert into t values (2001, 2), (2002, 3), (2003, 4), (2004, 5), (2005, 1); | ||
explain select * from t use index(idx1) where b > 2; | ||
id estRows task access object operator info | ||
Projection_5 3333.33 root globalindex__mem_index_lookup.t.a, globalindex__mem_index_lookup.t.b | ||
└─UnionScan_6 3333.33 root gt(globalindex__mem_index_lookup.t.b, 2) | ||
└─IndexLookUp_9 3333.33 root partition:all | ||
├─IndexRangeScan_7(Build) 3333.33 cop[tikv] table:t, index:idx1(b) range:(2,+inf], keep order:false, stats:pseudo | ||
└─TableRowIDScan_8(Probe) 3333.33 cop[tikv] table:t keep order:false, stats:pseudo | ||
select * from t use index(idx1) where b > 2; | ||
a b | ||
2002 3 | ||
2003 4 | ||
2004 5 | ||
rollback; |
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,32 @@ | ||
set tidb_enable_global_index=true; | ||
|
||
--echo # IntHandle | ||
drop table if exists t; | ||
CREATE TABLE `t` ( | ||
`a` int(11) DEFAULT NULL, | ||
`b` int(11) DEFAULT NULL, | ||
UNIQUE KEY `idx1` (`b`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`a`) PARTITIONS 5; | ||
|
||
begin; | ||
insert into t values (1, 2), (2, 3), (3, 4), (4, 5), (5, 1); | ||
explain select * from t use index(idx1) where b > 2; | ||
select * from t use index(idx1) where b > 2; | ||
rollback; | ||
|
||
--echo # CommonHandle | ||
drop table if exists t; | ||
CREATE TABLE `t` ( | ||
`a` year(4) primary key, | ||
`b` int(11) DEFAULT NULL, | ||
UNIQUE KEY `idx1` (`b`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`a`) PARTITIONS 5; | ||
|
||
begin; | ||
insert into t values (2001, 2), (2002, 3), (2003, 4), (2004, 5), (2005, 1); | ||
explain select * from t use index(idx1) where b > 2; | ||
select * from t use index(idx1) where b > 2; | ||
rollback; | ||
|