Created
March 15, 2018 14:06
-
-
Save kustodian/c62a9ee453b1ba33880205ad05e25002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
POSTGRES_VERSION='9.5' | |
# With how many clients to do this test | |
CLIENTS="20" | |
# Duration of each test | |
DURATION=3600 | |
PGBENCH="/usr/pgsql-${POSTGRES_VERSION}/bin/pgbench" | |
# fail on any errors | |
set -e | |
echot(){ | |
echo -en "$(date '+%F %T') $@" | |
} | |
wait_for_postgres(){ | |
while ! /usr/pgsql-${POSTGRES_VERSION}/bin/pg_isready -U postgres -d pgbench -q; do | |
sleep 1 | |
done | |
} | |
for num in $CLIENTS; do | |
for bench_type in '-N' '' '-S'; do | |
echot "Running VACUUM FULL ANALYZE... " | |
psql -q -U postgres -d pgbench -c 'VACUUM FULL ANALYZE' | |
echo Done | |
echot "Stopping postgres..." | |
systemctl stop postgresql-${POSTGRES_VERSION} | |
echo Done | |
echot "Dropping all page caches... " | |
echo 3 > /proc/sys/vm/drop_caches | |
echo Done | |
echot "Starting postgres..." | |
systemctl start postgresql-${POSTGRES_VERSION} | |
wait_for_postgres | |
echo Done | |
echot "Running pgbench:\n" | |
echo "$PGBENCH $bench_type -U postgres -c $num -j $num -T $DURATION pgbench" | |
$PGBENCH $bench_type -U postgres -c $num -j $num -T $DURATION pgbench | |
echo | |
done | |
echo -e "#####################################################################\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment