On Fri, 14 Feb 2025 at 15:36, Amit Kapila <amit.kapil...@gmail.com> wrote:
>
> Did you try to measure the performance impact of this change? We can
> try a few cases where DDL and DMLs are involved, missing publication
> (drop publication and recreate after a varying number of records to
> check the impact).

Since we don't have an exact scenario to compare with the patch
(because, in the current HEAD, when the publication is missing, an
error is thrown and the walsender/worker restarts), I compared the
positive case, where records are successfully replicated to the
subscriber, as shown below. For the scenario with the patch, I ran the
same test, where the publication is dropped before the insert,
allowing the walsender to check whether the publication is present.
The test results, which represent the median of 7 runs and the
execution run is in milliseconds, are provided below:

Brach/records  |  100     |  1000   |  10000     |  100000  |  1000000
Head               |   1.214  |  2.548  |  10.823    |  90.3       |  951.833
Patch              |   1.215  |  2.5485 |  10.8545 |  90.94     |   955.134
% diff              |   0.082  |   0.020   |   0.291   |   0.704    |    0.347

I noticed that the test run with patches is very negligible. The
scripts used for execution are attached.

> The other names for the option could be:
> skip_notexistant_publications, or ignore_nonexistant_publications. Can
> we think of any others?

How about using ignore_missing_publications or skip_missing_publications?

Regards,
Vignesh

Attachment: v3-0001-Skip-loading-the-publication-if-the-publication-d.patch
Description: Binary data

Attachment: v3-0002-Added-an-option-skip_not_exist_publication-which-.patch
Description: Binary data

#!/bin/bash
# set -e
echo 'Clean up'

pg_ctl stop -D data_N2
pg_ctl stop -D data_N1

rm -r data_* *log

echo 'Set up'

# Setup and start publisher
initdb -D data_N1 -U postgres

cat << EOF >> data_N1/postgresql.conf
wal_level = logical
logical_decoding_work_mem = 5GB
EOF
pg_ctl -D data_N1 start -w -l N1.log

initdb -D data_N2 -U postgres

cat << EOF >> data_N2/postgresql.conf
wal_level = logical
logical_decoding_work_mem = 5GB
port = 9000
EOF
pg_ctl -D data_N2 start -w -l N2.log

(
    echo -e "CREATE TABLE tab (id int);"
    echo -e "CREATE PUBLICATION pub;"
) | psql -U postgres

(
    echo -e "CREATE TABLE tab (id int);"
    echo -e "CREATE SUBSCRIPTION sub CONNECTION 'user=postgres' PUBLICATION pub WITH (synchronous_commit = 'remote_apply', streaming = off);"
) | psql -U postgres -p 9000

cat << EOF >> data_N1/postgresql.conf
synchronous_standby_name = 'sub'
EOF
pg_ctl -D data_N1 reload

#!/bin/bash

cat << EOF >> data_N1/postgresql.conf
synchronous_standby_names = 'sub'
EOF
pg_ctl -D data_N1 reload 

# This should be uncommented for running tests with patch
#psql -U postgres -d postgres -c "drop publication pub"

# The record cound should be updated for each of the runs
time (
    echo -e "INSERT INTO tab VALUES (generate_series(1, 10000000));"
) | psql -U postgres

Reply via email to