
drop table t;
create table t(i int, j int);
insert into t select g, g from generate_series(1,100000) g;
vacuum analyze t;
vacuum analyze t;
checkpoint;
set work_mem='10GB';
\timing

\echo many small groups

create temp table t2 on commit drop as select i, array_agg(j) from t group by i;
create temp table t2 on commit drop as select i, array_agg(j) from t group by i;
create temp table t2 on commit drop as select i, array_agg(j) from t group by i;
create temp table t2 on commit drop as select i, array_agg(j) from t group by i;
create temp table t2 on commit drop as select i, array_agg(j) from t group by i;

\echo one big group

create temp table t2 on commit drop as select array_agg(j) from t;
create temp table t2 on commit drop as select array_agg(j) from t;
create temp table t2 on commit drop as select array_agg(j) from t;
create temp table t2 on commit drop as select array_agg(j) from t;
create temp table t2 on commit drop as select array_agg(j) from t;
