scribase
Jobs, queues and partitionsversion 5.5.0

pg_partman

Create and drop time or number partitions for you.

What it is for

pg_partman manages native Postgres partitions: it creates future partitions ahead of time and can drop or detach old ones by a retention rule. Pair it with pg_cron to run its maintenance on a schedule.

Enable it

sql
create schema if not exists partman;
create extension if not exists pg_partman with schema partman;

Example

sql
create table events (
  id bigint generated always as identity,
  created_at timestamptz not null,
  payload jsonb
) partition by range (created_at);

select partman.create_parent(
  p_parent_table := 'public.events',
  p_control := 'created_at',
  p_interval := '1 day'
);

select cron.schedule('partman-maintenance', '0 * * * *', $$select partman.run_maintenance()$$);

Questions

How do I enable pg_partman?

Run create schema if not exists partman; create extension if not exists pg_partman with schema partman; in the SQL editor, or switch it on from the Extensions page in the console. You do not need superuser access.

Which version of pg_partman is installed?

5.5.0, on Postgres 17.6, as read from the running engine on 2026-10-08. Check yours with: select extversion from pg_extension where extname = 'pg_partman';

Upstream project: github.com/pgpartman/pg_partman

More jobs, queues and partitions extensions

  • pgmq Message queues in SQL: send, read with a visibility timeout, archive.
  • pg_cron Run SQL on a schedule written in cron syntax.