From: | Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Optimization of vacuum for logical replication |
Date: | 2019-08-21 09:20:18 |
Message-ID: | 3a833bdb-2696-2294-9ee2-f7a8deaae707@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg토토 커뮤니티SQL |
Hi, hackers.
Right now if replication level is rgeater or equal than "replica",
vacuum of relation copies all its data to WAL:
/*
* We need to log the copied data in WAL iff WAL archiving/streaming is
* enabled AND it's a WAL-logged rel.
*/
use_wal = XLogIsNeeded() && RelationNeedsWAL(NewHeap);
Obviously we have to do it for physical replication and WAL archiving.
But why do we need to do so expensive operation (actually copy all table
data three times) if we use logical replication?
Logically vacuum doesn't change relation so there is no need to write
any data to the log and process it by WAL sender.
I wonder if we can check that
1. wal_revel is "logical"
2. There are no physical replication slots
3. WAL archiving is disables
and in this cases do not write cloned relation to the WAL?
Small patch implementing such behavior is attached to this mail.
It allows to significantly reduce WAL size when performing vacuum at
multimaster, which uses logical replication between cluster nodes.
What can be wrong with such optimization?
--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachment | Content-Type | Size |
---|---|---|
logical_vacuum.patch | text/x-patch | 2.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bernd Helmle | 2019-08-21 09:34:34 | Re: Optimization of vacuum for logical replication |
Previous Message | Konstantin Knizhnik | 2019-08-21 08:54:29 | Re: Global temporary tables |