Re: sequences vs. synchronous replication

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: sequences vs. synchronous replication
Date: 2021-12-21 00:53:02
Message-ID: 8231183d-1077-5394-1ffa-0c9d8c3905b0@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/20/21 17:40, Tomas Vondra wrote:
> On 12/20/21 15:31, Peter Eisentraut wrote:
>> On 18.12.21 22:48, Tomas Vondra wrote:
>>> What do you mean by "not caching unused sequence numbers"? Reducing
>>> SEQ_LOG_VALS to 1, i.e. WAL-logging every sequence increment?
>>>
>>> That'd work, but I wonder how significant the impact will be. It'd
>>> bet it hurts the patch adding logical decoding of sequences quite a bit.
>>
>> It might be worth testing.  This behavior is ancient and has never
>> really been scrutinized since it was added.
>>
>
> OK, I'll do some testing to measure the overhead, and I'll see how much
> it affects the sequence decoding patch.
>

OK, I did a quick test with two very simple benchmarks - simple select
from a sequence, and 'pgbench -N' on scale 1. Benchmark was on current
master, patched means SEQ_LOG_VALS was set to 1.

Average of 10 runs, each 30 seconds long, look like this:

1) select nextval('s');

clients 1 4
------------------------------
master 39497 123137
patched 6813 18326
------------------------------
diff -83% -86%

2) pgbench -N

clients 1 4
------------------------------
master 2935 9156
patched 2937 9100
------------------------------
diff 0% 0%

Clearly the extreme case (1) is hit pretty bad, while the much mure
likely workload (2) is almost unaffected.

I'm not sure what conclusion to make from this, but assuming almost no
one does just nextval calls, it should be acceptable.

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ajin Cherian 2021-12-21 00:54:00 Re: row filtering for logical replication
Previous Message Michael Paquier 2021-12-21 00:46:37 Re: Confused comment about drop replica identity index