create table dim_1 (id int primary key, r double precision);
create table dim_2 (id int primary key, r double precision);
create table dim_3 (id int primary key, r double precision);
create table dim_4 (id int primary key, r double precision);
create table dim_5 (id int primary key, r double precision);
create table dim_6 (id int primary key, r double precision);
create table dim_7 (id int primary key, r double precision);
create table f (id int primary key, id1 int, id2 int, id3 int, id4 int, id5 int, id6 int, id7 int, p text);

insert into dim_1 select i, random() from generate_series(1,100000) s(i);
insert into dim_2 select i, random() from generate_series(1,100000) s(i);
insert into dim_3 select i, random() from generate_series(1,100000) s(i);
insert into dim_4 select i, random() from generate_series(1,100000) s(i);
insert into dim_5 select i, random() from generate_series(1,100000) s(i);
insert into dim_6 select i, random() from generate_series(1,100000) s(i);
insert into dim_7 select i, random() from generate_series(1,100000) s(i);

insert into f
select
  i,
  1 + mod((10000 * random())::int,100000),
  1 + mod((10000 * random())::int,100000),
  1 + mod((10000 * random())::int,100000),
  1 + mod((10000 * random())::int,100000),
  1 + mod((10000 * random())::int,100000),
  1 + mod((10000 * random())::int,100000),
  1 + mod((10000 * random())::int,100000)
from generate_series(1,1000000) s(i);

create index on f (id1);
create index on f (id2);
create index on f (id3);
create index on f (id4);
create index on f (id5);
create index on f (id6);
create index on f (id7);

analyze;

set max_parallel_workers_per_gather = 0;
set bloom_filter_pushdown_max = 10;

\timing on

set enable_hashjoin_bloom = off;

explain (costs off)
select * from f
  join dim_1 on (f.id1 = dim_1.id)
  join dim_2 on (f.id2 = dim_2.id)
  join dim_3 on (f.id3 = dim_3.id)
  join dim_4 on (f.id4 = dim_4.id)
  join dim_5 on (f.id5 = dim_5.id)
  join dim_6 on (f.id6 = dim_6.id)
  join dim_7 on (f.id7 = dim_7.id)
where dim_1.r < 0.5
  and dim_2.r < 0.5
  and dim_3.r < 0.5
  and dim_4.r < 0.5
  and dim_5.r < 0.5
  and dim_6.r < 0.5
  and dim_7.r < 0.5;

set enable_hashjoin_bloom = on;

explain (costs off)
select * from f
  join dim_1 on (f.id1 = dim_1.id)
  join dim_2 on (f.id2 = dim_2.id)
  join dim_3 on (f.id3 = dim_3.id)
  join dim_4 on (f.id4 = dim_4.id)
  join dim_5 on (f.id5 = dim_5.id)
  join dim_6 on (f.id6 = dim_6.id)
  join dim_7 on (f.id7 = dim_7.id)
where dim_1.r < 0.5
  and dim_2.r < 0.5
  and dim_3.r < 0.5
  and dim_4.r < 0.5
  and dim_5.r < 0.5
  and dim_6.r < 0.5
  and dim_7.r < 0.5;
