create table j1(i int, im5 int,  im100 int, im1000 int);
create table j2(i int, im5 int,  im100 int, im1000 int);

insert into j1 select i, i%5, i%100, i%1000 from generate_series(1, 10000000)i;
insert into j2 select * from j1;
insert into j1 values(1, 1, 1, 1), (1, 1, 1, 1);
analyze;

