Skip to content

Instantly share code, notes, and snippets.

@tavin
Created February 24, 2021 14:27
Show Gist options
  • Save tavin/87d4daef1ee7bbf7ce235036f6e2b45d to your computer and use it in GitHub Desktop.
Save tavin/87d4daef1ee7bbf7ce235036f6e2b45d to your computer and use it in GitHub Desktop.
pgbench.sh
#!/bin/bash
set -ex
scale=20 # table size factor; should not be less than $clients
clients=10 # number of concurrent sessions
jobs=$((`nproc`/2)) # threads i.e. how many cpus to use
duration=300 # length of test in seconds
progress=10 # progress reporting interval
filesystem=postgresql/pgbench
PATH="/usr/pgsql-9.5/bin:$PATH"
sudo zfs destroy "$filesystem" || true
sudo zfs create "$filesystem"
export PGPORT=5411 PGDATA=$(zfs get mountpoint "$filesystem" -Ho value)
sudo chown -R postgres: "$PGDATA"
initdb -A trust -E UTF8 --locale en_US.UTF8
pg_ctl start -w
createdb pgbench
pgbench -i -s "$scale" pgbench
pgbench -c "$clients" -j "$jobs" -T "$duration" -P "$progress" pgbench
sudo fuser -vkMm "$PGDATA"
sudo zfs destroy "$filesystem"
@tavin
Copy link
Author

tavin commented Feb 24, 2021

ssh postgres@wherever < pgbench.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment