#!/bin/sh

# Run on primary

DB="pgbench"
SCALE=`psql -d $DB -At -c "select count(*) from pgbench_branches"`
CLIENTS=1
TIME=5

while [ 1 ] ; do
  date
  echo Running pgbench updater for $TIME seconds
  pgbench -c $CLIENTS -s $SCALE -T $TIME -n -f teller-update.sql $DB
  psql -d $DB -c "vacuum pgbench_tellers;"
  psql -d $DB -c "checkpoint;"
  psql -d $DB -c "select pg_switch_xlog();"
done
