Skip to content

No PostgreSQL extensions; partitioning in process

Accepted.

2026-05-27 (the date the partition manager was added to the repository).

The platform stores a lot of time-ordered data: events, dispatch jobs, attempts, scheduled-job instances and their logs. Keeping every row forever is neither affordable nor useful, and deleting old rows with DELETE is slow and bloats tables. The standard answer is range partitioning by month, so old data goes away by dropping a whole partition.

PostgreSQL’s partitioning needs partitions to be created ahead of time and dropped later. The common ways to automate that are extensions: pg_partman to manage partitions and pg_cron to run the maintenance on a schedule.

Extensions are a deployment constraint:

  • Managed database services allow only an approved list of extensions, and that list changes on the provider’s schedule, not the project’s.
  • An extension differs between development and production. The development database is an embedded, vanilla PostgreSQL that ships the standard contrib modules but not third-party ones.
  • Operators of self-hosted databases have to install, version and upgrade them.

No extension is required. The platform runs on stock PostgreSQL.

Partitioning is done by the platform itself. A PartitionManager in the stream subsystem runs on a timer (every 24 hours by default) and, on each pass:

  • ensures monthly RANGE (created_at) partitions exist for the current month and the next three (FC_STREAM_PARTITION_MONTHS_FORWARD);
  • drops partitions whose whole date range ends before the retention cutoff (90 days by default, FC_STREAM_PARTITION_RETENTION_DAYS; 30 days for the scheduled-job history pair, FC_STREAM_PARTITION_RETENTION_DAYS_SCHEDULED_JOBS).

The managed tables are the events and dispatch-job tables with their read projections, the attempts table and the scheduled-job instance and log tables. Partitions are named <parent>_YYYY_MM, and the drop pass reads the suffix to compute a partition’s age. The manager checks that a parent really is partitioned before touching it. The work is leader-only DDL (see ADR 0017), so only one replica runs it.

The same code runs in development and production. The migrations partition the tables on every profile, including fcdev’s embedded database, so queries that omit the partition key and constraints that do not survive partitioning fail in development.

Scheduled work (cron-like jobs, retention, projections) is likewise run by the platform’s own subsystems rather than by pg_cron. For applications that genuinely need an extension, the supported route is their own database; the embedded PostgreSQL is vanilla, and adding PostGIS to it is a documented manual step for development only.

Good

  • Any managed PostgreSQL works, with no allow-list request or version coupling.
  • Development and production run identical maintenance code, so it is tested where it is written.
  • Retention is a platform setting visible in the environment reference, and dropping a partition is quick and releases the space.

Bad

  • The platform owns partition maintenance. If no node runs the manager for long enough, the forward partitions run out and inserts into the next month fail. The three-month look-ahead gives slack, and the database growth runbook covers it.
  • Retention is by whole month, so the on-disk window floats between the retention setting and one month more.
  • The manager has to be written and tested, including the case of a parent that is not partitioned.
  • Features that an extension would give cheaply (trigram search, scheduled SQL) have to be done in code or left out.
  • A read window wider than the partition retention returns nothing for the missing days, so the dispatch-job window setting should be kept at or below retention.
  • pg_partman and pg_cron. The usual solution, ruled out by the allow-list and parity concerns.
  • Unpartitioned tables with DELETE retention. Simple, but slow to clean and prone to bloat at the event rates the platform targets.
  • An external scheduled job (cron on a host or a cloud scheduler) running the DDL. It moves the dependency outside the platform without removing it.