#Pre condition:
#Create and initialize the database and set the export PGDATA 
export PGDATA=/data/akapila/workspace/master/data
export PGPORT=5433
export LD_LIBRARY_PATH=/data/akapila/workspace/master/installation/lib:$LD_LIBRARY_PATH

#for i in "shared_buffers no_of_readings"
for i in "8GB 5" 
do
shared_bufs=`echo $i | cut -d" " -f1`
no_of_readings=`echo $i | cut -d" " -f2`

# -----------------------------------------------

echo "Start of script for $shared_bufs $no_of_readings" >> test_results.txt



#Start the server
./postgres -c shared_buffers=$shared_bufs &

sleep 5 

        #Start taking reading
	for ((readcnt = 1 ; readcnt <= $no_of_readings ; readcnt++))
	do
		echo "================================================"  >> test_results.txt

		# Run parallel_count	
		./psql -d postgres -c "explain analyze select parallel_count(16384,0)" >> test_results.txt
		./psql -d postgres -c "explain analyze select parallel_count(16384,2)" >> test_results.txt
	done;

./pg_ctl stop
sleep 1


mv test_results.txt test_results_list_${shared_bufs}.txt
done;
