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 1oIwpj-0005Ni-4U for pgsql-general@arkaria.postgresql.org; Tue, 02 Aug 2022 18:41:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oIwpi-0006In-0e for pgsql-general@arkaria.postgresql.org; Tue, 02 Aug 2022 18:41:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIwpg-0006IQ-8c for pgsql-general@lists.postgresql.org; Tue, 02 Aug 2022 18:41:33 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIwpd-0004EO-EX for pgsql-general@lists.postgresql.org; Tue, 02 Aug 2022 18:41:31 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B8E7F32007F0; Tue, 2 Aug 2022 14:41:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 02 Aug 2022 14:41:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1659465686; x= 1659552086; bh=9CmXStUseoCZAJ6pIBfjS0+iw2ITJ3nnoOcEvC4xayA=; b=y 0qxZLdDog/QaP5hoCMmbZL+f60X4Y8lFmTe7fvBgzxkVB3uhNdCm44Mk7a/aogas qnzeXN6ROqiVvFxfouZnQaGB6ZI2TiPBIhgpRyCMD6DSHQEe52jVcHjblefE9w4q xQNGuWr+LHfcTPrHiyAHMykG7snnglHJ9I+ezuBywIVyFkdFnuERphl/8WU/qXxq snBk/g9DJlZtcHMPtMER6iVB+2isVCQgDUTtplj5e9Vx2prnn/GBd/NahevMK+R8 62RbKDfdspKr7kt4oY0Il8LX2ChLeq3Bk6vxSgDaKAMntjXB7TTWcqgEXNgRTkH0 sLwzTJdevsjoaYQsfeVEA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1659465686; x=1659552086; bh=9 CmXStUseoCZAJ6pIBfjS0+iw2ITJ3nnoOcEvC4xayA=; b=FbyfwkgVt1m9MGqHR 05jKcuTY0z9SiDMV1Rxz50DFTY5SIQ04atxsG0NLiOEOGOwW3isu6QNjmeUf7LCv Zbv+ZnmTKRoPCAR6xqQKEN7nw7UCUrLJdek4A31biMGgsHwV7dGEw9inDDjRZakk i9N1c/FRZAWwdZyV8eKUh9bWmNtmZrJ8iQOCnyVgX6d2la8CS8N0IipbbNgKbvNi CdZqw6sQoP83P4mS1zYmntOaC+agDJJH7w+1i8LqWNVKZpO5Kk+3NjBMfRF8b2KB wNJr4cK/9MGqhOkySX4VwPHFAxRqBDg0o90ZFEMuGxFoCSzHQG3ug9yVQx0I9ahA 7Daag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddvhedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepveevfeevfeeugeffkeekhfegieeufffgteeujedv gffhueejjefhkeejleegtdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 Aug 2022 14:41:25 -0400 (EDT) Subject: Re: Copying records from TABLE_A to TABLE_B (in the same database) To: Ron , pgsql-general list References: <5adcc923-889d-bb68-5a04-60125b6f0e96@gmail.com> From: Adrian Klaver Message-ID: <5c9cf0c3-e530-fb39-1409-096b343b2c75@aklaver.com> Date: Tue, 2 Aug 2022 11:41:24 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <5adcc923-889d-bb68-5a04-60125b6f0e96@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/2/22 11:37 AM, Ron wrote: > AWS RDS Postgresql 12.10 > > There are no indices or constraints (except for NOT NULL) on table_a. > > The two ways that I know are: >     INSERT INTO table_a SELECT * FROM table_b; > and >     \COPY table_a TO '/tmp/table_a.tsv' WITH (FORMAT BINARY); >     \COPY table_b FROM '/tmp/table_a.tsv' WITH (FORMAT BINARY); > > Is there a faster/better way? > Does table_a have existing records? If so do you care if there are duplicates? How large a data set are you talking about? -- Adrian Klaver adrian.klaver@aklaver.com