

\timing
create table r(ir int4range);
create index r_idx on r using gist (ir);
insert into r
  select int4range(g, g+10)
  from generate_series(1,1000000) g
  order by random();

create table s(ir int4range);
create index s_idx on r using gist (ir);
insert into s
  select int4range(g+5, g+15)
  from generate_series(1,1000000) g
  order by random();

set enable_mergejoin=false;
explain analyze
  select * from r, s where r.ir && s.ir;
explain analyze
  select * from r, s where r.ir && s.ir;

set enable_mergejoin=true;
explain analyze
  select * from r, s where r.ir && s.ir;
explain analyze
  select * from r, s where r.ir && s.ir;

drop table r;
drop table s;
