Creating extra monthly partitions in postgres using pg_partman #518
-
I have 2 partition tables whose partition key is on created_date and I have created monthly partitions. This was created at the time of creation of partition table using pg_partman. Then as part of the maintenance activity i updated the premake value to 12 on part_config table and then ran the function run_maintenance(). My idea is to have 12 new partitions ant any given point of time. Below is my observation and where my confusion is: When I ran run_maintenance() for 1st table which had data in partition MAR_2023, had create new extra partitions till MAR_2024. But for the 2nd table as the latest data was present in JAN_2023, it only created till DEC_2023. Is this an expected behavior ? What should i do to have 12 new partitions ahead of the current date even if the data in the partion is empty. Can this be achieved ? Thank You in advance ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes this is the expected default behavior. Future partition creation is based on the data that exists, not the tables that exist. This is to prevent endless child table creation when a table is no longer in use. If you want child tables to keep being created for a time-based partition set, no matter the data, set the This is not possible for integer based partitioning and is always based on the existing data. |
Beta Was this translation helpful? Give feedback.
Yes this is the expected default behavior. Future partition creation is based on the data that exists, not the tables that exist. This is to prevent endless child table creation when a table is no longer in use.
If you want child tables to keep being created for a time-based partition set, no matter the data, set the
infinite_time_partitions
column inpart_config
to true for that table.This is not possible for integer based partitioning and is always based on the existing data.