From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Olivier Gautherot <olivier@gautherot.net>
Cc: pgsql-general@postgresql.org
Subject: Re: Fast logical replication jump start with PG 10
Date: Sat, 26 May 2018 11:00:33 -0700
Message-ID: <a01d4eeb-21c5-d235-a18c-fe476d2db6a9@aklaver.com> (raw)
In-Reply-To: <CAJ7S9TUZJfcYEqQOxiLEy7d05NHfG7N0AyZYsG-4ngvb9PwLAQ@mail.gmail.com>
References: <CAJ7S9TVygExihaXt2E1bNH_0kGnx8bA62fmGreDGWTwb3_Pi7g@mail.gmail.com>
<729c1726-2e61-f03f-fe7e-c1dcf3f59e85@aklaver.com>
<CAJ7S9TWdYCi-FBhB4a5=gf7TfdZ=z6B+4wAQLAEJzZtoa0V3LA@mail.gmail.com>
<239dddd5-aa45-a7fe-b35a-085b978f8bd6@aklaver.com>
<CAJ7S9TUZJfcYEqQOxiLEy7d05NHfG7N0AyZYsG-4ngvb9PwLAQ@mail.gmail.com>
On 05/26/2018 06:23 AM, Olivier Gautherot wrote:
> Hi Adrian!
>
> On Sat, May 26, 2018 at 12:11 AM, Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
>
> On 05/25/2018 06:35 PM, Olivier Gautherot wrote:
>
> Hi Adrian, thanks for your reply. Here is the clarification.
>
> 1) It is indeed a pg_upgrade from 9.2 to 10.4. Depending on the
> test machine, it runs in between 15 and 20 minutes for just over
> 100GB. I can negotiate this time with our customer. The vacuum
> process took another 5 to 7 minutes. This this what I was
> referring to with the 30 minutes (point 3 in your questions)
>
> 2) After pg_upgrade, I published the tables on the database (in
> the sense "CREATE DATABASE") and subscribed to this publication
> on the second server (logical replication). The data copy
> processed started immediately and took around 1 hour. I then
> loaded the indexes, what took > another 2h20m. At that point the
> active-passive cluster was ready to go.
>
>
> The index creation was done on the replicated machine I presume,
> using what command?
>
>
> The sequence on the replicated machine was (pseudo-code to simplify the
> syntax):
> - pg_dump --section=pre-data -h master_machine master_database | psql -h
> replication_machine replication_database
> # This took seconds, "pre-data" discards the indexes
>
> - psql -h replication_machine -c "CREATE SUBSCRIPTION mysub CONNECTION
> "..." PUBLICATION mypub;" replication_database
> # This took about 1 hour for the initial sync
>
> - pg_dump --section=post-data -h master_machine master_database | psql
> -h replication_machine replication_database
> # This took 2h20m to load the various indexes
>
> This sequence follows the recommendation of section 14.4.3 in
> https://www.postgresql.org/docs/10/static/populate.html . If I stick to
> streaming as we do today (e.g. pg_upgrade and then rsync to the
> replication server), I can be ready in about 1 hour (more acceptable for
> the customer).
>
Just realized that by setting up the streaming as above you are already
doing basically the same thing as I suggested in my previous post.
Streaming and logical replication can exist at the same time:
https://www.postgresql.org/docs/10/static/logical-replication.html
"Logical replication is a method of replicating data objects and their
changes, based upon their replication identity (usually a primary key).
We use the term logical in contrast to physical replication, which uses
exact block addresses and byte-by-byte replication. PostgreSQL supports
both mechanisms concurrently, see Chapter 26. Logical replication allows
fine-grained control over both data replication and security."
So you could set up the logical replication after the streaming is done
using the copy_data=false clause and been done in a relatively short
period of time. At that point you could decide whether to keep the
streaming running or not.
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, olivier@gautherot.net
Subject: Re: Fast logical replication jump start with PG 10
In-Reply-To: <a01d4eeb-21c5-d235-a18c-fe476d2db6a9@aklaver.com>
References: <CAJ7S9TVygExihaXt2E1bNH_0kGnx8bA62fmGreDGWTwb3_Pi7g@mail.gmail.com> <729c1726-2e61-f03f-fe7e-c1dcf3f59e85@aklaver.com> <CAJ7S9TWdYCi-FBhB4a5=gf7TfdZ=z6B+4wAQLAEJzZtoa0V3LA@mail.gmail.com> <239dddd5-aa45-a7fe-b35a-085b978f8bd6@aklaver.com> <CAJ7S9TUZJfcYEqQOxiLEy7d05NHfG7N0AyZYsG-4ngvb9PwLAQ@mail.gmail.com> <a01d4eeb-21c5-d235-a18c-fe476d2db6a9@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox