
--alter system set shared_buffers ='4GB';
--restart
alter system set maintenance_work_mem = '1GB';
select pg_reload_conf();

show shared_buffers;

\timing

--------------------------------------
create unlogged table if not exists test (a int, b uuid) with (autovacuum_enabled=false);

insert into test (a,b) select i, gen_random_uuid() from generate_series(1,100*1000*1000) i;
select pg_size_pretty(pg_table_size('test'));
-- 4977 MB

vacuum test;

create index on test (a);
create index on test (b);
select pg_size_pretty(pg_total_relation_size('test'));
-- 10128 MB

--select max(ctid) from test;
-- (636942,106)

--select * from pg_backend_pid();

-- delete ~20% at the end
delete from test where ctid > '(510000,1)'::tid;

vacuum (verbose, truncate off, parallel 2) test;
