Skip to content

Instantly share code, notes, and snippets.

@simonmellor
Created November 7, 2017 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmellor/8c49dbd77772f74d8d83155893971f39 to your computer and use it in GitHub Desktop.
Save simonmellor/8c49dbd77772f74d8d83155893971f39 to your computer and use it in GitHub Desktop.
pgbench script
#!/bin/sh
: "${PGHOST?Need to set PGHOST}"
: "${PGPORT?Need to set PGPORT}"
: "${PGDATABASE?Need to set PGDATABASE}"
: "${PGUSER?Need to set PGUSER}"
: "${PGPASSWORD?Need to set PGPASSWORD}"
REPORT_NAME="/tmp/$PGHOST$PGPORT.txt"
touch "${REPORT_NAME}"
echo "$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$PGDATABASE" >> "$REPORT_NAME"
seed () {
echo "Seed" >> "$REPORT_NAME"
pgbench -i -s 30 "$PGDATABASE" >> "$REPORT_NAME" 2>&1
}
seed
echo "Single-Threaded" >> "$REPORT_NAME"
pgbench -c 1 -T 600 "$PGDATABASE" >> "$REPORT_NAME" 2>&1
seed
echo "Normal Load" >> "$REPORT_NAME"
pgbench -c 8 -j 2 -T 600 "$PGDATABASE" >> "$REPORT_NAME" 2>&1
seed
echo "Heavy Contention" >> "$REPORT_NAME"
pgbench -c 64 -j 4 -T 600 "$PGDATABASE" >> "$REPORT_NAME" 2>&1
seed
echo "Heavy Connections without Contention" >> "$REPORT_NAME"
pgbench -c 64 -j 4 -T 600 -N "$PGDATABASE" >> "$REPORT_NAME" 2>&1
seed
echo "Heavy Re-connection (simulates no connection pooling)" >> "$REPORT_NAME"
pgbench -c 8 -j 2 -T 600 -C "$PGDATABASE" >> "$REPORT_NAME" 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment