Migration question #684
-
Hello. Is there a way/workaround to copy data from a non- partitioned table to a pg_partman partitioned table by using a pg_partman procedure/function? So far i've tested partition_data_proc but that does the removal of data from the source table . I want to be able to have the data in the old table after the migration for a while , in the same time reducing the migration time to a partitioned table( by doing the actual delete/drop table at a subsequent time). My env - postgres 13-15 + pg_partman v5.0.0 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The built-in function that you used is for moving the data, so there is no option to keep the data in the old table using the built in functions. You can simply do an |
Beta Was this translation helpful? Give feedback.
-
Ok, got it, thanks. |
Beta Was this translation helpful? Give feedback.
The built-in function that you used is for moving the data, so there is no option to keep the data in the old table using the built in functions.
You can simply do an
INSERT INTO ... SELECT ... FROM
statement if you want to copy the data from one place to another. That will do it all in one transaction, so if it's a lot of data on a production system that may not be ideal. In that case you'd need to find a way to batch it and use some external tracking method to know where the last batch left off since all of the old data is still there.