Re: Logical replication performance

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Florian Philippon <florian(dot)philippon(at)doctolib(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Logical replication performance
Date: 2019-12-09 22:31:39
Message-ID: CAMkU=1w6Dn2RPYfgBV-YdLVEHKnPhEVfs7EmA4yFmqfRc7GsjQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Nov 29, 2019 at 11:06 AM Florian Philippon <
florian(dot)philippon(at)doctolib(dot)com> wrote:

>
> We tried another solution: we loaded a minimal schema (without indexes and
> constraints) on the subscriber and created the subscription. The initial
> copy phase was way faster (a few hours). Then we created indexes and
> constraints. Is this a suitable solution for production?
>

This is probably not suitable for production. Once the COPY is finished,
it still has to replicate row-by-row changes to the table rows which
occurred since the starting COPY snapshot. UPDATEs and DELETEs will
probably fail due to the lack of indexes on the “replica identity”
columns. This failure will make the entire transaction, including the
COPY, roll back to beginning. So you there will be no point at which you
can build the missing indexes without first losing all the work that was
done. If the master was quiescent (at least in regards to UPDATEs and
DELETEs) then it there will be no row-by-row changes to apply between the
start of the COPY and the start of transactional replication. In that
case, the COPY will have committed before the system discovers the problem
with the “replica identity”, giving you an opportunity to go build the
index without losing all of the work.

> Will the logical replication flow be buffered by the replication slots
> during index creation and get in sync afterwards or will it conflict due to
> locking issues?
>

It can't buffer in the middle of the transaction which includes the initial
COPY.

Cheers,

Jeff

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Fahiz Mohamed 2019-12-09 22:39:38 Re: Specific query taking time to process
Previous Message Michael Lewis 2019-12-09 19:03:15 Re: Specific query taking time to process