-
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.
planner,expression,util: scatter hotspot index in certain scenes by e…
- Loading branch information
1 parent
c102b6b
commit 6517f3b
Showing
18 changed files
with
1,223 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use test; | ||
drop table if exists test3, test5; | ||
create table test3(id int primary key clustered, a int, b int, unique key uk_expr((tidb_shard(a)),a)); | ||
create table test5(id int primary key clustered, a int, b int, unique key uk_expr((tidb_shard(a)),a,b)); | ||
explain format=brief select * from test3 where a=100; | ||
id estRows task access object operator info | ||
Projection 1.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Point_Get 1.00 root table:test3, index:uk_expr(tidb_shard(`a`), a) | ||
explain format=brief select * from test3 where a=100 and (b = 100 or b = 200); | ||
id estRows task access object operator info | ||
Projection 0.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Selection 0.00 root or(eq(test.test3.b, 100), eq(test.test3.b, 200)) | ||
└─Point_Get 1.00 root table:test3, index:uk_expr(tidb_shard(`a`), a) | ||
explain format=brief select * from test3 where tidb_shard(a) = 8; | ||
id estRows task access object operator info | ||
Projection 10.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─IndexLookUp 10.00 root | ||
├─IndexRangeScan(Build) 10.00 cop[tikv] table:test3, index:uk_expr(tidb_shard(`a`), a) range:[8,8], keep order:false, stats:pseudo | ||
└─TableRowIDScan(Probe) 10.00 cop[tikv] table:test3 keep order:false, stats:pseudo | ||
explain format=brief select * from test3 where a=100 or b = 200; | ||
id estRows task access object operator info | ||
Projection 8000.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Selection 8000.00 root or(and(eq(tidb_shard(test.test3.a), 8), eq(test.test3.a, 100)), eq(test.test3.b, 200)) | ||
└─TableReader 10000.00 root data:TableFullScan | ||
└─TableFullScan 10000.00 cop[tikv] table:test3 keep order:false, stats:pseudo | ||
explain format=brief select * from test3 where a=100 or a = 300; | ||
id estRows task access object operator info | ||
Projection 2.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Batch_Point_Get 2.00 root table:test3, index:uk_expr(tidb_shard(`a`), a) keep order:false, desc:false | ||
explain format=brief select * from test3 where a=100 or a = 300 or a > 997; | ||
id estRows task access object operator info | ||
Projection 8000.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Selection 8000.00 root or(and(eq(tidb_shard(test.test3.a), 8), eq(test.test3.a, 100)), or(and(eq(tidb_shard(test.test3.a), 227), eq(test.test3.a, 300)), gt(test.test3.a, 997))) | ||
└─TableReader 10000.00 root data:TableFullScan | ||
└─TableFullScan 10000.00 cop[tikv] table:test3 keep order:false, stats:pseudo | ||
explain format=brief select * from test3 where ((a=100 and b = 100) or a = 200) and b = 300; | ||
id estRows task access object operator info | ||
Projection 0.01 root test.test3.id, test.test3.a, test.test3.b | ||
└─TableReader 0.01 root data:Selection | ||
└─Selection 0.01 cop[tikv] eq(test.test3.b, 300), or(0, eq(test.test3.a, 200)) | ||
└─TableFullScan 10000.00 cop[tikv] table:test3 keep order:false, stats:pseudo | ||
explain format=brief select * from test3 where a = b; | ||
id estRows task access object operator info | ||
Projection 8000.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─TableReader 8000.00 root data:Selection | ||
└─Selection 8000.00 cop[tikv] eq(test.test3.a, test.test3.b) | ||
└─TableFullScan 10000.00 cop[tikv] table:test3 keep order:false, stats:pseudo | ||
explain format=brief select * from test3 where a = b and b = 100; | ||
id estRows task access object operator info | ||
Projection 0.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Selection 0.00 root eq(test.test3.b, 100) | ||
└─Point_Get 1.00 root table:test3, index:uk_expr(tidb_shard(`a`), a) | ||
explain format=brief select * from test5 where a=100 and b = 100; | ||
id estRows task access object operator info | ||
Projection 1.00 root test.test5.id, test.test5.a, test.test5.b | ||
└─Point_Get 1.00 root table:test5, index:uk_expr(tidb_shard(`a`), a, b) | ||
explain format=brief select * from test5 where (a=100 and b = 100) or (a=200 and b = 200); | ||
id estRows task access object operator info | ||
Projection 2.00 root test.test5.id, test.test5.a, test.test5.b | ||
└─Batch_Point_Get 2.00 root table:test5, index:uk_expr(tidb_shard(`a`), a, b) keep order:false, desc:false | ||
explain format=brief select a+b from test5 where (a, b) in ((100, 100), (200, 200)); | ||
id estRows task access object operator info | ||
Projection 2.00 root plus(test.test5.a, test.test5.b)->Column#5 | ||
└─Batch_Point_Get 2.00 root table:test5, index:uk_expr(tidb_shard(`a`), a, b) keep order:false, desc:false | ||
explain format=brief SELECT * FROM test3 WHERE a IN (100); | ||
id estRows task access object operator info | ||
Projection 1.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Point_Get 1.00 root table:test3, index:uk_expr(tidb_shard(`a`), a) | ||
explain format=brief SELECT * FROM test3 WHERE a IN (100, 200, 300); | ||
id estRows task access object operator info | ||
Projection 3.00 root test.test3.id, test.test3.a, test.test3.b | ||
└─Batch_Point_Get 3.00 root table:test3, index:uk_expr(tidb_shard(`a`), a) keep order:false, desc:false | ||
drop table if exists test3, test5; |
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,22 @@ | ||
use test; | ||
drop table if exists test3, test5; | ||
create table test3(id int primary key clustered, a int, b int, unique key uk_expr((tidb_shard(a)),a)); | ||
create table test5(id int primary key clustered, a int, b int, unique key uk_expr((tidb_shard(a)),a,b)); | ||
|
||
explain format=brief select * from test3 where a=100; | ||
explain format=brief select * from test3 where a=100 and (b = 100 or b = 200); | ||
explain format=brief select * from test3 where tidb_shard(a) = 8; | ||
explain format=brief select * from test3 where a=100 or b = 200; | ||
explain format=brief select * from test3 where a=100 or a = 300; | ||
explain format=brief select * from test3 where a=100 or a = 300 or a > 997; | ||
explain format=brief select * from test3 where ((a=100 and b = 100) or a = 200) and b = 300; | ||
explain format=brief select * from test3 where a = b; | ||
explain format=brief select * from test3 where a = b and b = 100; | ||
explain format=brief select * from test5 where a=100 and b = 100; | ||
explain format=brief select * from test5 where (a=100 and b = 100) or (a=200 and b = 200); | ||
explain format=brief select a+b from test5 where (a, b) in ((100, 100), (200, 200)); | ||
explain format=brief SELECT * FROM test3 WHERE a IN (100); | ||
explain format=brief SELECT * FROM test3 WHERE a IN (100, 200, 300); | ||
|
||
drop table if exists test3, test5; | ||
|
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
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
Oops, something went wrong.