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 1mnFBd-0004Hh-7e for pgsql-general@arkaria.postgresql.org; Wed, 17 Nov 2021 07:16:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mnFBc-00081g-4Z for pgsql-general@arkaria.postgresql.org; Wed, 17 Nov 2021 07:16:52 +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 1mnFBb-00081X-Kv for pgsql-general@lists.postgresql.org; Wed, 17 Nov 2021 07:16:51 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnFBW-0005Bs-68 for pgsql-general@lists.postgresql.org; Wed, 17 Nov 2021 07:16:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EUi04xXSF+UU69nbdxDx6Y8O5aFLtlTJoP5eciHaXBM=; b=iO7bCHQtg61b3gy/KLdbTQ2saD E59OFX910cXZe43Sr4MJ8fk1yADApUdRNo6xZpVk5UYly5TkhjR/xlLhb++7RWEjubemNxYBEmu+h yr0KdBZakFQEoM4cekxR06lJFUSFKzyn9mhC+/EomgnTqZFoApVLtv1atFPJe62K3Tb8=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1mnFBU-0004XU-5E; Wed, 17 Nov 2021 08:16:44 +0100 Date: Wed, 17 Nov 2021 08:16:44 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Akheel Ahmed Cc: pgsql-general@lists.postgresql.org Subject: Re: create all indexes and triggers in a schema after bulk load Message-ID: <20211117071643.GA11260@depesz.com> Reply-To: depesz@depesz.com References: <06fbb436-d81b-4428-029c-91e6f1181ed5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <06fbb436-d81b-4428-029c-91e6f1181ed5@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Nov 17, 2021 at 05:13:35PM +1000, Akheel Ahmed wrote: > Hi Group > > I am looking at doing a CDC-based upgrade using the following steps: > > > 1. pg_dump schema on source, but exclude indexes and triggers > > 2. recreate schema on target > > 3. Do a full load from source to target > > 4. Recreate all the indexes and triggers on the target > > The migration will automatically switch from full load to CDC when all > tables are fully loaded. > > Is there a way to just recreate all indexes and triggers using a separate > pg_dump on source to capture the ddl and then run it on the target? There is no need for separate pg_dump. Just dump once, with -Fc, or (better) -Fd, and then use pg_restore -l/-L. depesz