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 1oIwr0-0005RL-Ln for pgsql-general@arkaria.postgresql.org; Tue, 02 Aug 2022 18:42:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oIwqz-0004as-FL for pgsql-general@arkaria.postgresql.org; Tue, 02 Aug 2022 18:42:53 +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 1oIwqz-0004aj-33 for pgsql-general@lists.postgresql.org; Tue, 02 Aug 2022 18:42:53 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oIwqx-0003Hj-8P for pgsql-general@lists.postgresql.org; Tue, 02 Aug 2022 18:42:52 +0000 Received: by mail-oi1-x22a.google.com with SMTP id bb16so17457012oib.11 for ; Tue, 02 Aug 2022 11:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=6IhXg7Q82jZoSR7kPIeLNvZSfXGicexYjFtIKmoNvkM=; b=noHkGLjN4DOwYGRFi1Au5fqYoljNCbfQAC3YyTD1SfL2IrxqeotKYZjo5J8w5SmE9a ElpDPji4kbV7dyynV0DTcDyhy7zR2lMvQc6F3eQbSCkzb+4KrwvITgX1jtcmB46feVtn c/tIEL38i3zLDDB3SYD+w9x86VdWrEnu6WUn0X16NJ990sFRqE0frPPmHaZfl5T8QomO Tey2ar9o9n2apFfoIKdSow9RyAvwM39haC8KpjkzSeeVwmfzrTXTadRpJvpCUfsxEX5K zknFUjcV8X5K4wLrLMbawIJei7KRMPyiJvb5T7HfVssQ8caaDRyLKNgceROoVt/GrwMI grjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=6IhXg7Q82jZoSR7kPIeLNvZSfXGicexYjFtIKmoNvkM=; b=DpV9vVtt3L2LRJXaRR9SrVzoh7wAHVydmfCXFAYTNVD0Jztkl3A3UjXFF3rd1u86fk 96JwOQCDU+M0Pbd7xI4jS4DP6SPbPyAMViKrnm8zOjb3IzcWMnQF4ZXnz33fZ5iDn64R 7q9Nyla1D5FEnuFEPINBh83/imn+g9M+mH7d0hxclLlaUJjYiE+wUhcMgKD82TO0LirB MM06q4gwQQ8k2W0dU8PcqAMsvOSKwWz+xZ/Se5IlYGO7aRz9c0w1Dxvg6z8Nztjqf3Eg ZEo9Pv0fE1HfzTled00FUPop/NQtNwLC/yobRpqA60VRDXoFevO7nAiBQy7F1rJuGaw8 dKYw== X-Gm-Message-State: ACgBeo3Qfk+Ow90tc5nVSbtbKudSeFPgQjdoSPQV6GSkacAdvhFX2PH8 pff8U7WEn7rixT2yNl0GviOoRxCS3X8= X-Google-Smtp-Source: AA6agR5fEprjalJkknDqlG0Bowovqtu8CmwqrzVn6EX2zPeedUMeBTRa+FWdjoTnS2HzPHbr+0WLQQ== X-Received: by 2002:a54:4591:0:b0:33a:fc8a:b698 with SMTP id z17-20020a544591000000b0033afc8ab698mr316761oib.173.1659465769485; Tue, 02 Aug 2022 11:42:49 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id fo22-20020a0568709a1600b0010eaeee89a1sm2472658oab.46.2022.08.02.11.42.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Aug 2022 11:42:49 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------axDs0Fz0zzglmsR0vJLKg9fG" Message-ID: Date: Tue, 2 Aug 2022 13:42:48 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Copying records from TABLE_A to TABLE_B (in the same database) Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <5adcc923-889d-bb68-5a04-60125b6f0e96@gmail.com> <0f9d8171-7b10-2e3e-50a3-a4fa3fbfc0e2@gmail.com> From: Ron In-Reply-To: <0f9d8171-7b10-2e3e-50a3-a4fa3fbfc0e2@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------axDs0Fz0zzglmsR0vJLKg9fG Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/2/22 13:41, Rob Sargent wrote: > On 8/2/22 12:37, 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? >> > create view ? No, we need separate copies. -- Angular momentum makes the world go 'round. --------------axDs0Fz0zzglmsR0vJLKg9fG Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit On 8/2/22 13:41, Rob Sargent wrote:
On 8/2/22 12:37, 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?

create view ?

No, we need separate copies.

--
Angular momentum makes the world go 'round.
--------------axDs0Fz0zzglmsR0vJLKg9fG--