# pg_partman — Postgres extension

> Create and drop time or number partitions for you.

Source: https://scribase.com/extensions/pg_partman

Category: Jobs, queues and partitions. Version: 5.5.0. Optional, enabled per project.

## About

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()$$);
```

Upstream: https://github.com/pgpartman/pg_partman