Optimization of vacuum for logical replication

Поиск
Список
Период
Сортировка
От Konstantin Knizhnik
Тема Optimization of vacuum for logical replication
Дата
Msg-id 3a833bdb-2696-2294-9ee2-f7a8deaae707@postgrespro.ru
обсуждение исходный текст
Ответы Re: Optimization of vacuum for logical replication  (Bernd Helmle <mailings@oopsware.de>)
Список pgsql-hackers
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


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Konstantin Knizhnik
Дата:
Сообщение: Re: Global temporary tables
Следующее
От: Bernd Helmle
Дата:
Сообщение: Re: Optimization of vacuum for logical replication