pg_fkpart
pg_fkpart
pg_fkpart : Table partitioning by foreign key utility
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2500 | pg_fkpart | pg_fkpart | 1.7.0 | OLAP | GPL-2.0 | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
----d-- | No | No | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | pgfkpart |
| See Also | citus pg_partman timescaledb periods temporal_tables btree_gist emaj table_version |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 1.7.0 | 18 17 16 15 14 | pg_fkpart | - |
| RPM | PIGSTY | 1.7.0 | 18 17 16 15 14 | pg_fkpart_$v | - |
| DEB | PIGSTY | 1.7.0 | 18 17 16 15 14 | postgresql-$v-pg-fkpart | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 |
el8.aarch64 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 |
el9.x86_64 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 |
el9.aarch64 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 |
el10.x86_64 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 |
el10.aarch64 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 | PGDG 1.7.0 |
d12.x86_64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
d12.aarch64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
d13.x86_64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
d13.aarch64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
u22.x86_64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
u22.aarch64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
u24.x86_64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
u24.aarch64 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 | PIGSTY 1.7.0 |
Source
pig build pkg pg_fkpart; # build debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_fkpart; # install via package name, for the active PG version
pig install pg_fkpart -v 18; # install for PG 18
pig install pg_fkpart -v 17; # install for PG 17
pig install pg_fkpart -v 16; # install for PG 16
pig install pg_fkpart -v 15; # install for PG 15
pig install pg_fkpart -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION pg_fkpart;Usage
pg_fkpart enables partitioning PostgreSQL tables based on a foreign key relationship.
All functions reside in the pgfkpart schema.
Create the Extension
CREATE EXTENSION pg_fkpart;Partition a Table by Foreign Key
SELECT pgfkpart.partition_with_fk(
'public', -- schema of the table to partition
'my_table', -- table to partition
'public', -- schema of the foreign key table
'fk_table', -- foreign key table
true -- support SQL RETURNING
);Unpartition a Table
SELECT pgfkpart.unpartition_with_fk('public', 'my_table');Index Management
Propagate indexes and constraints from parent to all child tables:
SELECT pgfkpart.dispatch_index('public', 'my_table');Drop an index across all child tables:
SELECT pgfkpart.drop_index('public', 'my_table', 'my_index_name');Drop a unique constraint across all child tables:
SELECT pgfkpart.drop_unique_constraint('public', 'my_table', 'my_constraint_name');Partition Tracking
The extension maintains a pgfkpart.partition table that records all partitioned tables,
including schema, table name, foreign key column, and foreign table information.
Last updated on