Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3Sip-0000Z7-5r for pgsql-general@arkaria.postgresql.org; Sat, 23 Jan 2021 23:53:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l3Sin-0008Ii-FN for pgsql-general@arkaria.postgresql.org; Sat, 23 Jan 2021 23:53:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3Sin-0008Ib-4F for pgsql-general@lists.postgresql.org; Sat, 23 Jan 2021 23:53:37 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l3Sig-0007oD-3i for pgsql-general@lists.postgresql.org; Sat, 23 Jan 2021 23:53:36 +0000 Received: by mail-oi1-x230.google.com with SMTP id x71so10618424oia.9 for ; Sat, 23 Jan 2021 15:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=f4STJf0rxzr+Mi4ASeCxqQNlWrFVhigvpf/GuKeXwe0=; b=ry0OfBRDRhL3rY2gfqMbZIrGsqsnN4uEY0CC26SFy+UaglQU/16xJ7Z2vZQz6w0Tn0 1AAdD0zrYeIetH6FVGGS/qvZcApgErT1bxKyqbsNagA0JNOXXoOW3ydOjoLD6Rvq9No8 xGHVwQtGBG5og2WK/KxfEhV4Io8S6cdFoa1Ym2aTPz2ukno/kqyyiIf7eB3x29zgFGsV EmzRNVAF5dKvgJGr2xmIAb3mYDA+VH1kUZvtizJpHKnVu5Zfsi8qkDX0geI4SySIL8yH tNWHY4drZTqz6118yyxGB9loX6xM8YZzpyTftRnyZblmJEP99uLisdPs/hF3N8FNzLZx QjrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=f4STJf0rxzr+Mi4ASeCxqQNlWrFVhigvpf/GuKeXwe0=; b=a1hOMJMIs9Cd+UQ3rgZOIGuIK9p2TeU9vxDZA3KX8pvaTCDwIyaX/3fISCdEq/hqdO mARnrRZzdHh3KOYJtU1Qik1YoT3kMH7rl63b8wCTtY45/CsKbJABVX/LmcAUjdTGADYk jcUPLBGGRl61WSvAzgJ6eEXGPFYF2MF/K0J1Ac9EPVsRa+y6sxjN7bD7h7akjN7UHv4d yQfoPK5/O/sVgH+RRFtB3+CLl+CdgiWY8rqWgQtOY3hdv/zkO6D+Wulz8LmV7eRjkTFP 0mw7EeGDuLGCk5lxm6J/Zvzf6C9EuQtzwoGzjjbFUH9f4++zUGavuWuhTnAN8YWHSmZj x6pA== X-Gm-Message-State: AOAM531IglWsRGAYXE23/UVhHUUHVgWI5fJAm0UlFvUm5fsRcPf7E0aX u+WcdOrxpcX+2/1cIUkD0/HdFvmntPiaIQ== X-Google-Smtp-Source: ABdhPJxApKcOYGzlV+cgDZ72ewpC4IcThGw67KkeKwCWxWRXO9YMOAhBH6bfKXXJiSLNGac/hUDRwQ== X-Received: by 2002:aca:3150:: with SMTP id x77mr7295274oix.52.1611446007636; Sat, 23 Jan 2021 15:53:27 -0800 (PST) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id q6sm2658036ota.44.2021.01.23.15.53.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Jan 2021 15:53:27 -0800 (PST) Subject: Re: Question about logically replicating a multi-TB database To: pgsql-general@lists.postgresql.org References: <35409a7a-427b-58bd-0975-eb1abc280340@gmail.com> From: Ron Message-ID: <6d4c6c3b-19c0-80e7-87f1-d6b8a0cc7638@gmail.com> Date: Sat, 23 Jan 2021 17:53:26 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------6CD1D5AF56558E68E06EA58C" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------6CD1D5AF56558E68E06EA58C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 1/23/21 5:37 PM, Avinash Kumar wrote: > Hi, > > > On Sat, Jan 23, 2021 at 7:28 PM Ron > wrote: > > > https://www.postgresql.org/docs/12/logical-replication-architecture.html > > "30.5.1. Initial Snapshot > The initial data in existing subscribed tables are snapshotted and > copied in > a parallel instance of a special kind of apply process. This process will > create its own temporary replication slot and copy the existing data. > Once > existing data is copied, the worker enters synchronization mode, which > ensures that the table is brought up to a synchronized state with the > main > apply process by streaming any changes that happened during the > initial data > copy using standard logical replication. Once the synchronization is > done, > the control of the replication of the table is given back to the main > apply > process where the replication continues as normal." > > We've got a Large and busy database which we need to migrate to AWS, > and a > shared 1Gbps pipe between the source and AWS. > > How does one set up publish/subscribe in such a case?  All the > examples I've > seen are with trivially small databases. > > If the speed is the concern, You should try avoiding the copy of the > initial snapshot and rather do it manually through a parallel pg_dump and > pg_restore. > And rather disable the initial snapshot copy once the parallel restore is > completed. Is this what you mean? source> CREATE PUBLICATION ... target> CREATE SUBSCRIPTION ... WITH (COPY_DATA='false'); source> pg_dump -d database ... transport dump files to target system target> pg_restore ... target> ALTER SUBSCRIPTION ... REFRESH PUBLICATION -- Angular momentum makes the world go 'round. --------------6CD1D5AF56558E68E06EA58C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 1/23/21 5:37 PM, Avinash Kumar wrote:
Hi,


On Sat, Jan 23, 2021 at 7:28 PM Ron <ronljohnsonjr@gmail.com> wrote:

https://www.postgresql.org/docs/12/logical-replication-architecture.html

"30.5.1. Initial Snapshot
The initial data in existing subscribed tables are snapshotted and copied in
a parallel instance of a special kind of apply process. This process will
create its own temporary replication slot and copy the existing data. Once
existing data is copied, the worker enters synchronization mode, which
ensures that the table is brought up to a synchronized state with the main
apply process by streaming any changes that happened during the initial data
copy using standard logical replication. Once the synchronization is done,
the control of the replication of the table is given back to the main apply
process where the replication continues as normal."

We've got a Large and busy database which we need to migrate to AWS, and a
shared 1Gbps pipe between the source and AWS.

How does one set up publish/subscribe in such a case?  All the examples I've
seen are with trivially small databases.
 
If the speed is the concern, You should try avoiding the copy of the initial snapshot and rather do it manually through a parallel pg_dump and pg_restore. 
And rather disable the initial snapshot copy once the parallel restore is completed.

Is this what you mean?

source> CREATE PUBLICATION ...
target> CREATE SUBSCRIPTION ... WITH (COPY_DATA='false');
source> pg_dump -d database ...
transport dump files to target system
target> pg_restore ...
target> ALTER SUBSCRIPTION ... REFRESH PUBLICATION


--
Angular momentum makes the world go 'round.
--------------6CD1D5AF56558E68E06EA58C--