sortbench_1m.sh.txt
text/plain
Filename: sortbench_1m.sh.txt
Type: text/plain
Part: 0
#!/bin/bash
sec=5
dbname=postgres
records=1000000
mod=100
psql -c "drop table if exists t" $dbname
psql -c "create table t (a bigint not null)" $dbname
psql -c "insert into t select x % $mod from generate_series(1,$records) x" $dbname
psql -c "vacuum freeze t" $dbname
for i in {1..32}
do
echo $i
psql -c "explain analyze select * from t order by a offset 1000000000" $dbname | grep -E "Memory|Disk"
echo "select * from t order by a offset 1000000000" > bench.sql
for loops in {1..3}
do
pgbench -n -M prepared -T $sec -f bench.sql $dbname | grep tps
done
psql -c "alter table t add column c$i bigint" $dbname
psql -c "update t set c$i = a" $dbname
psql -c "vacuum full t" $dbname
psql -c "vacuum freeze t" $dbname
done