CREATE EXTENSION intarray;


CREATE TABLE gistgrandparent( a int[] );

INSERT INTO gistgrandparent SELECT array[g] FROM generate_series(1, 150000) g;

CREATE INDEX test_idx ON gistgrandparent USING gist( a);

-- Check that all the rows can be found using the index
do $$
declare
  i int;
begin
  for i in 1..120000 loop
    if (i % 10000) = 0 then
      raise notice 'working on %', i;
    end if;

    perform * from gistgrandparent where a @> array[i];
    if not found then
      raise notice 'failed for %', i;
    end if;
  end loop;
end;
$$ language plpgsql;
