#!/bin/bash export PATH=$PATH:$PWD/bin dbname=postgres rows=1000000 secs=10 extra_cols=48 psql -c "alter system set max_parallel_workers_per_gather = 0;" $dbname > /dev/null psql -c "select pg_reload_conf();" $dbname > /dev/null psql -c "create extension if not exists pg_prewarm;" $dbname > /dev/null for c in $(seq 0 $extra_cols) do psql -c "drop table if exists t1;" $dbname > /dev/null sql="create table t1 (vlen text not null default ''" i=0; while [ $i -lt $c ] do sql="$sql,c$i int not null default 0"; ((i+=1)) done sql="$sql,a int not null" i=$c; while [ $i -lt $extra_cols ] do sql="$sql,c$i int not null default 0"; ((i+=1)) done sql="$sql);" psql -c "$sql" $dbname > /dev/null psql -c "insert into t1 (a) select a from generate_series(1,$rows) a;" $dbname > /dev/null psql -c "vacuum freeze analyze t1;" $dbname > /dev/null psql -c "select pg_prewarm('t1');" $dbname > /dev/null psql -c "checkpoint;" $dbname > /dev/null echo "select sum(a) from t1;" > bench.sql for i in {1..3} do echo -n "extra_cols $c run $i " pgbench -n -f bench.sql -M prepared -T $secs $dbname | grep tps done done