pg_prttn_tools
pg_prttn_tools · Provides PL/pgSQL tools for managing inheritance-based partition tables.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100329 | pg_prttn_tools | pg_prttn_tools | 0.5 | OLAP | MIT | SQL |
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
pg_prttn_tools manages old-style PostgreSQL inheritance partitions with generated check constraints, rules, and insert triggers. It predates declarative partitioning and should be used only when an existing inheritance-based design requires its exact behavior.
Core Workflow
The time helpers accept year, month, day, hour, or minute, derive the child-table name and bounds, then optionally create an insert-routing rule.
Function Families
create_child_tableclones a parent withLIKE ... INCLUDING ALL, adds inheritance, a check constraint, and optionally a routing rule.part_list_check,part_list_add, andpart_list_create_triggerhandle list-valued partitions.part_time_check,part_time_add, andpart_time_create_triggerhandle timestamp ranges.part_list_time_check,part_list_time_add, andpart_list_time_create_triggercombine list and time dimensions.drop_ins_trigger,part_merge, andpart_time_cleanupremove routing objects, merge a child back into its parent, or drop old time-named tables.
Privileges and Destructive Operations
The control file requires a superuser, fixes the extension schema as prttn_tools, and the SQL changes function ownership to postgres. The functions build DDL by concatenating their text arguments, so pass only trusted identifiers and values.
part_time_cleanup executes DROP TABLE for every table in a schema whose name starts with the supplied prefix and sorts before the computed timestamp suffix. Confirm the exact prefix and inspect candidate tables before calling it. These helpers create inheritance children, not native PARTITION BY partitions; planner pruning, constraints, indexes, and routing behavior therefore follow the older inheritance model.