perf_various_percentages.sh

application/octet-stream

Filename: perf_various_percentages.sh
Type: application/octet-stream
Part: 1
Message: RE: row filtering for logical replication
pub_port=5432
sub_port=5433

master=/home/postgres/install_row_filter_master_rel/bin/
patched=/home/postgres/install_row_filter_rel/bin/


# $1=filter
# $2=install_patch
# $3=pgbench_sql_file
run()
{

filter=$1
install_patch=$2
pgbench_sql_file=$3

${install_patch}pg_ctl -D data_pub stop -m i
${install_patch}pg_ctl -D data_sub stop -m i
rm -rf data_pub data_sub pub.log sub.log

${install_patch}initdb -D data_pub -U postgres
${install_patch}initdb -D data_sub -U postgres

cat << EOF >> data_pub/postgresql.conf
wal_level = logical
port = $pub_port
# synchronous_commit = off
checkpoint_timeout = 1d
max_wal_size = 24GB
min_wal_size = 15GB
autovacuum = off
EOF

cat << EOF >> data_sub/postgresql.conf
wal_level = logical
port = $sub_port
checkpoint_timeout = 1d
max_wal_size = 24GB
min_wal_size = 15GB
autovacuum = off
EOF

${install_patch}pg_ctl -D data_pub start -l pub.log
${install_patch}pg_ctl -D data_sub start -l sub.log

${install_patch}psql -d postgres -p $pub_port -c "create table test(key int, value text, data jsonb, primary key(key, value));\
                                                  create publication pub1 for table test $filter ;"
${install_patch}psql -d postgres -p $sub_port -c "create table test(key int, value text, data jsonb, primary key(key, value));"
${install_patch}psql -d postgres -p $sub_port -c "create subscription sub1 connection 'dbname=postgres port=$pub_port' publication pub1;"

#sleep 3
#echo synchronous_standby_names = \'sub1\' >> data_pub/postgresql.conf
#${install_patch}pg_ctl -D data_pub reload
#sleep 3

echo -------------------- | tee -a all.res
echo ${install_patch} | tee -a all.res
echo $filter | tee -a all.res
echo warm up

${install_patch}pgbench -f $pgbench_sql_file -r -n -T 300

echo start
${install_patch}pgbench -f $pgbench_sql_file -r -n -t 10 | tee -a all.res

}

rm all.res

# 0% rows match
run "where (key > 10000000)" ${patched} insert.sql | tee insert.log

# 25% rows match
run "where (key > 7500000)" ${patched} insert.sql | tee -a insert.log

# 50% rows match
run "where (key > 5000000)" ${patched} insert.sql | tee -a insert.log

# 75% rows match
run "where (key > 2500000)" ${patched} insert.sql | tee -a insert.log

# 100% rows match
run "where (key > 0)" ${patched} insert.sql | tee -a insert.log

# HEAD
run "" ${master} insert.sql | tee -a insert.log