#1. Initialization only once
export PGDATA=~/data_16GB
rm -rf ~/data_16GB
./initdb
./postgres -c shared_buffers=7GB -p 9267 &
sleep 10
./psql -p 9267 -c "create extension pg_prewarm;" postgres 

./pgbench -i -s 1200 -d postgres -p 9267 -U kiran
./pg_ctl stop


# Testcase Results for 8 clients and 8 threads
./postgres -c shared_buffers=7GB -p 9267 &
sleep 10

#Load OS, shared buffers
./psql -p 9267 -d postgres -f load_all_buffers.sql

./pgbench -S -c 8 -j 8 -T 1800 -p 9267 postgres
./pgbench -S -c 8 -j 8 -T 1800 -p 9267 postgres
./pgbench -S -c 8 -j 8 -T 1800 -p 9267 postgres
./pgbench -S -c 8 -j 8 -T 1800 -p 9267 postgres
./psql -p 9267 -c "checkpoint;" postgres 
./pg_ctl stop


# Testcase Results for 16 clients and 16 threads

./postgres -c shared_buffers=7GB -p 9267 &
sleep 10

#Load OS, shared buffers
./psql -p 9267 -d postgres -f load_all_buffers.sql

./pgbench -S -c 16 -j 16 -T 1800 -p 9267 postgres
./pgbench -S -c 16 -j 16 -T 1800 -p 9267 postgres
./pgbench -S -c 16 -j 16 -T 1800 -p 9267 postgres
./pgbench -S -c 16 -j 16 -T 1800 -p 9267 postgres

./psql -p 9267 -c "checkpoint;" postgres 
./pg_ctl stop


# Testcase Results for 32 clients and 32 threads
./postgres -c shared_buffers=7GB -p 9267 &
sleep 10

#Load OS, shared buffers
./psql -p 9267 -d postgres -f load_all_buffers.sql

./pgbench -S -c 32 -j 32 -T 1800 -p 9267 postgres
./pgbench -S -c 32 -j 32 -T 1800 -p 9267 postgres
./pgbench -S -c 32 -j 32 -T 1800 -p 9267 postgres
./pgbench -S -c 32 -j 32 -T 1800 -p 9267 postgres

./psql -p 9267 -c "checkpoint;" postgres 
./pg_ctl stop


# Testcase Results for 64 clients and 64 threads
./postgres -c shared_buffers=7GB -p 9267 &
sleep 10

#Load OS, shared buffers
./psql -p 9267 -d postgres -f load_all_buffers.sql

./pgbench -S -c 64 -j 64 -T 1800 -p 9267 postgres
./pgbench -S -c 64 -j 64 -T 1800 -p 9267 postgres
./pgbench -S -c 64 -j 64 -T 1800 -p 9267 postgres
./pgbench -S -c 64 -j 64 -T 1800 -p 9267 postgres

./psql -p 9267 -c "checkpoint;" postgres 
./pg_ctl stop
