PGROOT=`pwd`/tmp_install
PGDB=`pwd`/tmpdb
PGBIN=$PGROOT/usr/local/pgsql/bin

export PATH="$PGBIN:$PATH"
export LD_LIBRARY_PATH="$PGROOT/usr/local/pgsql/lib"
rm -rf "$PGDB"; $PGBIN/initdb -D "$PGDB"

#echo -e "session_pool_size=2" >> $PGDB/postgresql.auto.conf
echo "
#  fsync=off
max_connections = 2000
parallel_setup_cost=0
parallel_tuple_cost=0
min_parallel_table_scan_size=0
max_parallel_workers_per_gather=4
max_parallel_workers = 100
max_worker_processes = 128

" >> $PGDB/postgresql.auto.conf

$PGBIN/pg_ctl -w -t 5 -D "$PGDB" -l server.log start
$PGBIN/createdb test
export PGDATABASE=test
$PGBIN/psql -f init_test.sql
$PGBIN/psql -t -c "SELECT version()"
# $PGBIN/pgbench -n -r -f .../sub_120.sql -c 200 -j 200 -T 120
$PGBIN/pgbench -n -r -f sub_120.sql -c 25 -j 25 -T 1800
$PGBIN/pg_ctl -w -t 5 -D "$PGDB" stop
sleep 2
coredumpctl
