Repartitioning old data #548
-
I have a question regarding the creation of a table and enabling native partitioning on it. Then detaching old partitions and finally deleting them. What I would like to understand is, what is the process of after reimporting old data to the parent table, how do I trigger a recreation for older partitions? So for example say if I detached and deleted partitions ab_r2021q1 and ab_r2021q2 from parent table ab but kept partitions ab_r2021q3 and ab_r2021q4 because they were less than 6 months old. Then on a future date after the creation of new partition ab_r2022q1, reimported data from the deleted ab_r2021q1 back to the parent table ab, is possible to recreate partition ab_r2021q1 with run_maintenance_proc()? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
If I'm understanding, you're wanting to drop old partitions via retention then add them back? Not sure I understand the reasoning for that, but if that's the design pattern you want, I would suggest that you leave the retention settings at their default so that the child table is simply detached vs getting fully dropped. Then if you need to add it back again later, you can simply reattach that child. pg_partman never automatically recreates old partitions after a partition set has already been made. It is only worried about future table creation. If you need to do that, you will have to do so manually. |
Beta Was this translation helpful? Give feedback.
-
@keithf4 Thanks for your response.
Exactly. So I that I can basically free up space from the db and if I need analytic reimport it back to the database.
Currently I have retention = '6 months' and retention_keep_table=true so that when I run the maintenance proc, the table isn't dropped merely detached.
I'll keep this in mind. |
Beta Was this translation helpful? Give feedback.
If I'm understanding, you're wanting to drop old partitions via retention then add them back? Not sure I understand the reasoning for that, but if that's the design pattern you want, I would suggest that you leave the retention settings at their default so that the child table is simply detached vs getting fully dropped. Then if you need to add it back again later, you can simply reattach that child.
pg_partman never automatically recreates old partitions after a partition set has already been made. It is only worried about future table creation. If you need to do that, you will have to do so manually.