pg_fkpart

Table partitioning by foreign key utility

Overview

PackageVersionCategoryLicenseLanguage
pg_fkpart1.7.0OLAPGPL-2.0SQL
IDExtensionBinLibLoadCreateTrustRelocSchema
2500pg_fkpartNoNoNoYesNoNopgfkpart
Relatedcitus pg_partman timescaledb periods temporal_tables btree_gist emaj table_version

Version

TypeRepoVersionPG VerPackageDeps
EXTMIXED1.7.01817161514pg_fkpart-
RPMPIGSTY1.7.01817161514pg_fkpart_$v-
DEBPIGSTY1.7.01817161514postgresql-$v-pg-fkpart-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
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
u26.x86_64
u26.aarch64

Build

You can build the DEB packages for pg_fkpart using pig build:

pig build pkg pg_fkpart         # build DEB packages

Install

You can install pg_fkpart directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_fkpart;          # Install for current active PG version
pig ext install -y pg_fkpart -v 18  # PG 18
pig ext install -y pg_fkpart -v 17  # PG 17
pig ext install -y pg_fkpart -v 16  # PG 16
pig ext install -y pg_fkpart -v 15  # PG 15
pig ext install -y pg_fkpart -v 14  # PG 14
dnf install -y pg_fkpart_18       # PG 18
dnf install -y pg_fkpart_17       # PG 17
dnf install -y pg_fkpart_16       # PG 16
dnf install -y pg_fkpart_15       # PG 15
dnf install -y pg_fkpart_14       # PG 14
apt install -y postgresql-18-pg-fkpart   # PG 18
apt install -y postgresql-17-pg-fkpart   # PG 17
apt install -y postgresql-16-pg-fkpart   # PG 16
apt install -y postgresql-15-pg-fkpart   # PG 15
apt install -y postgresql-14-pg-fkpart   # PG 14

Create Extension:

CREATE EXTENSION pg_fkpart;

Usage

pg_fkpart: Table partitioning by foreign key utility

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 Modified 2026-05-01: update extension data (aaef844)