Skip to content

Commit de0bf4e

Browse files
committed
v4.2.0 PG12 support. Fixed unlogged table support. Allow NOT VALID constraints. Bug fixes. See CHANGELOG for more details.
1 parent 7761854 commit de0bf4e

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ If you're still trying to evaluate whether partitioning is a good choice for you
1919

2020
INSTALLATION
2121
------------
22-
Requirement: PostgreSQL >= 9.5
22+
Requirement:
2323

24-
Recommended: pg_jobmon (>=v1.4.0). PG Job Monitor will automatically be used if it is installed and setup properly.
24+
* PostgreSQL >= 9.5.
25+
26+
Recommended:
27+
28+
* Native partitioning is highly recommended over trigger-based and PG11+ is HIGHLY recommended over PG10.
29+
* pg_jobmon (>=v1.4.0). PG Job Monitor will automatically be used if it is installed and setup properly.
2530
https://github.com/omniti-labs/pg_jobmon
2631

2732
In the directory where you downloaded pg_partman, run

doc/pg_partman.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@ If you have an existing partition set and you'd like to migrate it to pg_partman
1515

1616
### Child Table Property Inheritance
1717

18-
For this extension, most of the attributes of the child partitions are all obtained from the original parent. This includes defaults, indexes (primary keys, unique, clustering, etc), foreign keys (optional), tablespace, & constraints. Note that for PostgreSQL 10, indexes, foreign keys, unlogged status (see Notes below), & tablespaces for native partitioning are done through a template table instead. For PG11+, unlogged status and unique indexes that don't include the parition column require the template table; all other properties are managed by the parent again. The WITH OIDS property is no longer officially supported as of the release of PostgreSQL 12 since it was dropped there.
18+
For this extension, most of the attributes of the child partitions are all obtained from the original parent. This includes defaults, indexes (primary keys, unique, clustering, etc), foreign keys, tablespaces, & constraints. Note that for PostgreSQL 10, indexes, foreign keys, unlogged status (see Notes below), & tablespaces for native partitioning are done through a template table instead. For PG11+, unlogged status and unique indexes that don't include the partition column require the template table; all other properties are managed by the parent again. The WITH OIDS property is no longer officially supported as of the release of PostgreSQL 12 since it was dropped there.
1919

20-
Privileges & ownership are inherited by default for non-native partitioning, but not for native partitioning. Unless you need direct access to the child tables, this should not be needed. You can set the `inherit_privileges` option if this is needed (see config table information below).
20+
Privileges & ownership are inherited by default for non-native partitioning, but NOT for native partitioning. Also note that this inheritance is only at child table creation and isn't automatically retroactive when changed (see `reapply_privileges()`). Unless you need direct access to the child tables, this should not be needed. You can set the `inherit_privileges` option if this is needed (see config table information below). Note that inheriting privileges to the children requires running a superuser owned function that uses SECURITY DEFINER.
2121

22-
When privileges are being inherited, whenever a new partition is created it will obtain its privilege & ownership information from what the parent has at that time. Previous partition privileges are not changed. If previous partitions require that their privileges be updated, a separate function is available. This is kept as a separate process due to being an expensive operation when the partition set grows larger.
23-
24-
For PG10 and older, the defaults, indexes, unlogged status, tablespace & constraints on the parent (or template table) are only applied to newly created partitions and are not retroactively set on ones that already existed. For P11, only indexes and unlogged status applied to the template table are automatically applied to new children; all other properties applied to the parent should automatically apply to all child tables.
22+
For PG10 and older, defaults, indexes, unlogged status, tablespace & constraints on the parent (or template table) are only applied to newly created partitions and are not retroactively set on ones that already existed. For P11, only indexes and unlogged status applied to the template table are automatically applied to new children. All other properties, except privileges, applied to the parent should automatically apply to all child tables immediately when set.
2523

2624
The new IDENTITY feature introduced in PG10 is only supported in natively partitioned tables and the automatic generation of new sequence values using this feature is only supported when data is inserted through the parent table, not directly into the children.
2725

2826
IMPORTANT NOTES:
2927

30-
* The template table feature in use for PostgreSQL 10+ to handle certain features is only a temporary solution to help speed up native partitioning adoption. As things are handled better natively (as they were in PG11), the use of the template table will be phased out quickly from pg_partman. So please plan ahead for quick major version upgrades if you use this feature.
28+
* The template table feature in use for PostgreSQL 10+ to handle certain features is only a temporary solution to help speed up native partitioning adoption. As things are handled better natively (as they were in PG11), the use of the template table will be phased out quickly from pg_partman. So please plan ahead for quick major version upgrades if you use this feature and check release notes carefully for changes.
3129

32-
* The UNLOGGED status was moved to the template table as of v4.2.0 of pg_partman. This is due to an inconsistency in the way the property is handled when either enabling or disabling UNLOGGED on the parent table of a native partition set. That property does not actually change when the ALTER command is written so new child tables will continue to use the property that existed before. So if you wanted to change a partition set from UNLOGGED to LOGGED for all future children, it does not work. With the property now being managed on the template table, changing it there will allow the change to propogate to newly created children. Pre-existing child tables will have to be changed manually, but that has always been the case.
30+
* The UNLOGGED status was moved to the template table as of v4.2.0 of pg_partman. This is due to an inconsistency in the way the property is handled when either enabling or disabling UNLOGGED on the parent table of a native partition set. That property does not actually change when the ALTER command is written so new child tables will continue to use the property that existed before. So if you wanted to change a partition set from UNLOGGED to LOGGED for all future children, it does not work. With the property now being managed on the template table, changing it there will allow the change to propogate to newly created children. Pre-existing child tables will have to be changed manually, but that has always been the case. See reported bug at https://www.postgresql.org/message-id/flat/15954-b61523bed4b110c4%40postgresql.org
3331

3432
### Sub-partitioning
3533

@@ -50,7 +48,7 @@ Keep in mind that for subpartition sets, when a parent table has a child dropped
5048

5149
One of the big advantages of partitioning is a feature called **constraint exclusion** (see docs for explanation of functionality and examples http://www.postgresql.org/docs/current/static/ddl-partitioning.html#DDL-PARTITIONING-CONSTRAINT-EXCLUSION). The problem with most partitioning setups however, is that this will only be used on the partitioning control column. If you use a WHERE condition on any other column in the partition set, a scan across all child tables will occur unless there are also constraints on those columns. And predicting what a column's values will be to precreate constraints can be very hard or impossible. `pg_partman` has a feature to apply constraints on older tables in a partition set that may no longer have any edits done to them ("old" being defined as older than the `optimize_constraint` config value). It checks the current min/max values in the given columns and then applies a constraint to that child table. This can allow the constraint exclusion feature to potentially eliminate scanning older child tables when other columns are used in WHERE conditions. Be aware that this limits being able to edit those columns, but for the situations where it is applicable it can have a tremendous affect on query performance for very large partition sets. So if you are only inserting new data this can be very useful, but if data is regularly being inserted/updated throughout the entire partition set, this is of limited use. Functions for easily recreating constraints are also available if data does end up having to be edited in those older partitions. Note that constraints managed by PG Partman SHOULD NOT be renamed in order to allow the extension to manage them properly for you. For a better example of how this works, please see this blog post: http://www.keithf4.com/managing-constraint-exclusion-in-table-partitioning
5250

53-
Adding these constraints could potentially cause contention with the data contained in those tables and also make pg_partman maintenance take a long time to run. As of version 4.1+ of pg_partman, there is now a "constraint_valid" column in the part_config(_sub) table to set whether these constraints should be set NOT VALID on creation. While this can make the creation of the constraint(s) nearly instantaneous, constraint exclusion cannot be used until it is validated. This is why constraints are not added as NOT VALID by default.
51+
Adding these constraints could potentially cause contention with the data contained in those tables and also make pg_partman maintenance take a long time to run. As of version 4.2+ of pg_partman, there is now a "constraint_valid" column in the part_config(_sub) table to set whether these constraints should be set NOT VALID on creation. While this can make the creation of the constraint(s) nearly instantaneous, constraint exclusion cannot be used until it is validated. This is why constraints are added as valid by default.
5452

5553
NOTE: This may not work with sub-partitioning. It will work on the first level of partitioning, but is not guarenteed to work properly on further sub-partition sets depending on the interval combinations and the optimize_constraint value. Ex: Weekly -> Daily with a daily optimize_constraint of 7 won't work as expected. Weekly constraints will get created but daily sub-partition ones likely will not.
5654

0 commit comments

Comments
 (0)