Re: How to copy rows into same table efficiently

2021-10-26 Thread Michael Lewis
On Tue, Oct 26, 2021 at 1:07 AM Arun Suresh wrote: > Current approach taken is to build a query like below: > INSERT INTO mytable (col1, col2, col3, col4) SELECT col1, 'XYZ', col3, > col4 FROM mytable WHERE col2 = 'ABCD' > > Is there a better way to do this? > There could be other tables with for

Re: How to copy rows into same table efficiently

2021-10-26 Thread David G. Johnston
On Tue, Oct 26, 2021 at 2:06 AM Ron wrote: > Anyway, for millions of rows, I might use COPY instead of INSERT > (depending > on how many millions, how many indices, how large the rows, how fast the > machine, etc. > > I don't imagine using COPY TO to write the data to a file and then COPY FROM to

Re: How to copy rows into same table efficiently

2021-10-26 Thread Ron
On 10/26/21 1:04 AM, Arun Suresh wrote: Dear PG experts, We have a tenant discriminator column in our tables to enable storage of data from multiple tenants. This column is also part of the composite primary key. The customers may request creation of a tenant copy, which means if they curren

How to copy rows into same table efficiently

2021-10-26 Thread Arun Suresh
Dear PG experts, We have a tenant discriminator column in our tables to enable storage of data from multiple tenants. This column is also part of the composite primary key. The customers may request creation of a tenant copy, which means if they currently have a tenant id "ABCD", they would like t