| 1 |
--source include/have_ndb.inc |
| 2 |
# |
| 3 |
# Tests of table partotioned across a large number |
| 4 |
# of fragments. Intended to test possible issues |
| 5 |
# with large signal fanout, breaking the '1::4 rule' |
| 6 |
# |
| 7 |
|
| 8 |
|
| 9 |
create table parent(a int primary key, b int) engine=ndb; |
| 10 |
create table child(a int, b int, primary key(a,b)) engine=ndb; |
| 11 |
|
| 12 |
alter table parent partition by key(a) partitions 128; |
| 13 |
alter table child partition by key(a,b) partitions 128; |
| 14 |
|
| 15 |
insert into parent values (1,1), (2,2), (3,3), (4,4); |
| 16 |
insert into parent select a+4, b+4 from parent; |
| 17 |
insert into parent select a+8, b+8 from parent; |
| 18 |
insert into parent select a+16, b+16 from parent; |
| 19 |
insert into parent select a+32, b+32 from parent; |
| 20 |
insert into parent select a+64, b+64 from parent; |
| 21 |
insert into parent select a+128, b+128 from parent; |
| 22 |
|
| 23 |
insert into child select * from parent; |
| 24 |
analyze table parent, child; |
| 25 |
|
| 26 |
let $query = |
| 27 |
select straight_join count(*) from parent |
| 28 |
join child as c1 on c1.a = parent.b |
| 29 |
join child as c2 on c2.a = parent.b |
| 30 |
join child as c3 on c3.a = parent.b |
| 31 |
join child as c4 on c4.a = parent.b |
| 32 |
join child as c5 on c5.a = parent.b |
| 33 |
join child as c6 on c6.a = parent.b |
| 34 |
join child as c7 on c7.a = parent.b |
| 35 |
join child as c8 on c8.a = parent.b |
| 36 |
join child as c9 on c9.a = parent.b |
| 37 |
join child as c10 on c10.a = parent.b |
| 38 |
join child as c11 on c11.a = parent.b |
| 39 |
join child as c12 on c12.a = parent.b |
| 40 |
join child as c13 on c13.a = parent.b |
| 41 |
join child as c14 on c14.a = parent.b |
| 42 |
join child as c15 on c15.a = parent.b |
| 43 |
join child as c16 on c16.a = parent.b |
| 44 |
where parent.b < 2 |
| 45 |
; |
| 46 |
|
| 47 |
set ndb_join_pushdown = false; |
| 48 |
--replace_column 10 # 11 # |
| 49 |
eval explain $query; |
| 50 |
eval $query; |
| 51 |
|
| 52 |
set ndb_join_pushdown = true; |
| 53 |
--replace_column 10 # 11 # |
| 54 |
eval explain $query; |
| 55 |
eval $query; |
| 56 |
|
| 57 |
drop table parent, child; |
| 58 |
|
| 59 |
CREATE TABLE partitioned ( server_id int(11) NOT NULL, t12counter int(11) NOT NULL, pt12counter int(10) unsigned NOT NULL, updatetime timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (server_id) USING HASH ) ENGINE=ndb DEFAULT CHARSET=latin1 PARTITION BY KEY (server_id) PARTITIONS 56; |
| 60 |
|
| 61 |
insert into partitioned values (1,0,0,NULL); |
| 62 |
|
| 63 |
## Partition ID for row 1 = 52 (big-endian) or 19 (little-endian) |
| 64 |
--replace_regex /p52/pX/ /p19/pX/ |
| 65 |
select partition_name,table_rows from information_schema.PARTITIONS where table_name='partitioned' and table_rows>0; |
| 66 |
|
| 67 |
## Partition ID for row 1 = 52 (big-endian) or 19 (little-endian) |
| 68 |
--replace_regex /p52/pX/ /p19/pX/ |
| 69 |
explain select * from partitioned where server_id=1; |
| 70 |
|
| 71 |
insert into partitioned values (2,0,0,NULL); |
| 72 |
|
| 73 |
## Partition ID for row 2 = 30 (big-endian) or 1 (little-endian) |
| 74 |
--replace_regex /p30/pY/ /p1/pY/ |
| 75 |
select partition_name,table_rows from information_schema.PARTITIONS where table_name='partitioned' and table_rows>0 order by partition_name limit 1; |
| 76 |
|
| 77 |
## Partition ID for row 2 = 30 (big-endian) or 1 (little-endian) |
| 78 |
--replace_regex /p30/pY/ /p1/pY/ |
| 79 |
explain select * from partitioned where server_id=2; |
| 80 |
|
| 81 |
drop table partitioned; |