create table p (id int primary key, val text) partition by hash (id);

create table p0 partition of p for values with (modulus 8, remainder 0);
create table p1 partition of p for values with (modulus 8, remainder 1);
create table p2 partition of p for values with (modulus 8, remainder 2);
create table p3 partition of p for values with (modulus 8, remainder 3);
create table p4 partition of p for values with (modulus 8, remainder 4);
create table p5 partition of p for values with (modulus 8, remainder 5);
create table p6 partition of p for values with (modulus 8, remainder 6);
create table p7 partition of p for values with (modulus 8, remainder 7);

create table t as select i, md5(i::text) from generate_series(1,1000000) s(i);
vacuum analyze t;

checkpoint;

\timing
insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;

insert into p select * from t;
truncate p;
