Re: Copying records from TABLE_A to TABLE_B (in the same database) - Mailing list pgsql-general

From Ron
Subject Re: Copying records from TABLE_A to TABLE_B (in the same database)
Date
Msg-id 6a0b6197-c0ce-f0a0-2b2f-18f2b6e9b0fa@gmail.com
Whole thread Raw
In response to Re: Copying records from TABLE_A to TABLE_B (in the same database)  (Rob Sargent <robjsargent@gmail.com>)
Responses Re: Copying records from TABLE_A to TABLE_B (in the same database)
List pgsql-general
On 8/2/22 13:59, Rob Sargent wrote:
On 8/2/22 12:51, Thomas Kellerer wrote:
Ron schrieb am 02.08.2022 um 20:37:
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?

The INSERT is most probably faster then \copy

Another option is to have a trigger on table_a
to automatically replay all DML on table_b


Logical replication might be another option.
Although I am not sure if that is even possible inside
the samme database.
I know it's tricky inside the same server
(between different databases)



If you can get outside sql, the bulk copy facilities (CopyManager in java) is blindingly fast for me.

??

--
Angular momentum makes the world go 'round.

pgsql-general by date:

Previous
From: Ron
Date:
Subject: Re: Copying records from TABLE_A to TABLE_B (in the same database)
Next
From: Rob Sargent
Date:
Subject: Re: Copying records from TABLE_A to TABLE_B (in the same database)