Re: First draft of the PG 15 release notes
Euler Taveira <euler@eulerto.com>
On Thu, May 12, 2022, at 11:22 AM, Bruce Momjian wrote:
> On Thu, May 12, 2022 at 11:12:54AM -0300, Euler Taveira wrote:
> OB> On Thu, May 12, 2022, at 11:03 AM, Bruce Momjian wrote:
> >
> > I looked at that but thought that everyone would already assume we
> > skipped replication of empty transactions, and I didn't see much impact
> > for the user, so I didn't include it.
> >
> > It certainly has an impact on heavy workloads that replicate tables with few
> > modifications. It receives a high traffic of 'begin' and 'commit' messages that
> > the previous Postgres versions have to handle (discard). I would classify it as
> > a performance improvement for logical replication. Don't have a strong opinion
> > if it should be mentioned or not.
>
> Oh, so your point is that a transaction that only has SELECT would
> previously send an empty transaction? I thought this was only for apps
> that create literal empty transactions, which seem rare.
No. It should be a write transaction. If you have a replication setup that
publish only table foo (that isn't modified often) and most of your
workload does not contain table foo, Postgres sends 'begin' and 'commit'
messages to subscriber even if there is no change to replicate.
Let me show you an example:
postgres=# CREATE TABLE foo (a integer primary key, b text);
CREATE TABLE
postgres=# CREATE TABLE bar (c integer primary key, d text);
CREATE TABLE
postgres=# CREATE TABLE baz (e integer primary key, f text);
CREATE TABLE
postgres=# CREATE PUBLICATION pubfoo FOR TABLE foo;
CREATE PUBLICATION
postgres=# SELECT pg_create_logical_replication_slot('slotfoo', 'pgoutput');
pg_create_logical_replication_slot
------------------------------------
(slotfoo,0/E709AC50)
(1 row)
Let's create a transaction without table foo:
postgres=# BEGIN;
BEGIN
postgres=*# INSERT INTO bar (c, d) VALUES(1, 'blah');
INSERT 0 1
postgres=*# INSERT INTO baz (e, f) VALUES(2, 'xpto');
INSERT 0 1
postgres=*# COMMIT;
COMMIT
As you can see, the replication slot contains messages for that transaction.
Although, table bar and baz are NOT published, the begin (B) and commit (C)
messages that refers to this transaction are sent to subscriber.
postgres=# SELECT chr(get_byte(data, 0)) FROM
pg_logical_slot_peek_binary_changes('slotfoo', NULL, NULL,
'proto_version', '1', 'publication_names', 'pubfoo');
chr
-----
B
C
(2 rows)
If you execute another transaction without table foo, there will be another B/C
pair.
postgres=# DELETE FROM baz WHERE e = 2;
DELETE 1
postgres=# SELECT chr(get_byte(data, 0)) FROM
pg_logical_slot_peek_binary_changes('slotfoo', NULL, NULL,
'proto_version', '1', 'publication_names', 'pubfoo');
chr
-----
B
C
B
C
(4 rows)
Let's create a transaction that uses table foo but also table bar:
postgres=# BEGIN;
BEGIN
postgres=*# INSERT INTO foo (a, b) VALUES(100, 'asdf');
INSERT 0 1
postgres=*# INSERT INTO bar (c, d) VALUES(200, 'qwert');
INSERT 0 1
postgres=*# COMMIT;
COMMIT
In this case, there will be other messages since the publication pubfoo
publishes table foo. ('I' means there is an INSERT for table foo).
postgres=# SELECT chr(get_byte(data, 0)), length(data) FROM
pg_logical_slot_peek_binary_changes('slotfoo', NULL, NULL,
'proto_version', '1', 'publication_names', 'pubfoo');
chr | length
-----+--------
B | 21
C | 26
B | 21
C | 26
B | 21
R | 41
I | 25
C | 26
(8 rows)
In summary, a logical replication setup sends 47 bytes per skipped transaction.
v15 won't send the first 2 B/C pairs. Discussion started here [1].
[1] https://postgr.es/m/CAMkU=1yohp9-dv48FLoSPrMqYEyyS5ZWkaZGD41RJr10xiNo_Q@mail.gmail.com
--
Euler Taveira
EDB https://www.enterprisedb.com/
Commits
-
Doc: last minute adjustment to the release notes
- bb76510a07f3 15.0 landed
-
Doc: more tweaking of v15 release notes.
- 780add2c32a7 15.0 landed
-
Doc: further adjust notes about pg_upgrade_output.d.
- fbd2bd15b011 16.0 landed
- 796aa20a11b4 15.0 landed
-
Doc: add list of major features to the v15 release notes.
- a2ab0ad88cf8 15.0 landed
-
relnotes: update item about public schema permission change
- f5135d2aba87 15.0 landed
-
relnotes: update ordered partition scan item
- de89d8711e2b 15.0 landed
-
relnotes: add Heikki to UTF8 item
- 335e444f2269 15.0 landed
-
relnotes: improve UTF8 text item in relation to ASCII
- 9499c0fcf488 15.0 landed
-
relnotes: add null logical replication item
- 3715850ecc52 15.0 landed
-
relnotes: adjust several logical replication items and FK text
- 25285e5d4ee5 15.0 landed
-
relnotes: mention non-exclusive backup mode was deprecated
- 6bfecf33f6ed 15.0 landed
-
relnotes: add author to in-memory sorts item
- d70b95a7178a 15.0 landed
-
relnotes: update for non-exclusive backup mode removal
- da82c6246986 15.0 landed
-
relnote: improve sorting entries
- 922d1a27e9bd 15.0 landed
-
relnotes: adjustments from Álvaro Herrera
- 78ccd6cca48d 15.0 landed
-
relnotes: update foreign key partition and add sort items
- 279d957efebb 15.0 landed
-
relnotes: more adjustments
- 38fbbb5bb293 15.0 landed
-
relnotes: logical replication permissions checked by subscrib.
- 581c4e5b3185 15.0 landed
-
relnotes: adjustments
- a3c5f56c213e 15.0 landed
-
relnotes: remove sequence replication and update 'postgres -C'
- 653443ed83f0 15.0 landed
-
relnote: extensive updates
- 9d89bb8a025d 15.0 landed
-
relnotes: "training" -> "trailing"
- 3c534949bbb0 15.0 landed
-
Standardize references to Zstandard as <productname>
- 586955dddecc 15.0 cited
-
pgstat: Update docs to match the shared memory stats reality.
- b3abca68106d 15.0 cited
-
Raise a WARNING for missing publications.
- 8f2e2bbf1453 15.0 cited
-
Skip empty transactions for logical replication.
- d5a9d86d8ffc 15.0 cited
-
Optionally disable subscriptions on error.
- 705e20f8550c 15.0 cited
-
Allow root-owned SSL private keys in libpq, not only the backend.
- 2a1f84636dc3 14.3 cited
-
Use COPY FREEZE in pgbench for faster benchmark table population.
- 06ba4a63b85e 15.0 cited