drop table if exists testresults; create table testresults (testname text, seconds numeric, tblsize bigint); drop table if exists tmp; create temporary table tmp (b1 bytea, b2 bytea, b3 bytea, b4 bytea, b5 bytea, b6 bytea, b7 bytea, b8 bytea, b9 bytea, b10 bytea); do $$ declare iterations int4 := 20; i int4; iter int4; testname text; data bytea; nrows int4; begintime numeric; endtime numeric; begin for testname, data, nrows in select * from tests where enabled loop raise notice 'running % iterations of test ''%''', iterations, testname; for iter in 1..iterations loop truncate tmp; checkpoint; begintime := extract(epoch from clock_timestamp()); for i in 1..nrows by 500 loop insert into tmp select data, data, data, data, data, data, data, data, data, data from generate_series(1, 500); end loop; endtime := extract(epoch from clock_timestamp()); insert into testresults values (testname, endtime - begintime, pg_total_relation_size('tmp')); end loop; end loop; end; $$; select * from testresults;