Catalogue / aha-2025-audits-table-partitioning

Aha! partitioned its largest Postgres table, the audit history, by month without copying or moving the whole table

Aha!. Audits table (change history) in the Rails application's Postgres database.

Organisation
Aha!
Evidence
Reported from production
Source
Partitioning a large table in PostgreSQL with Rails

Aha! engineering blog, published 2025-04-28

Records

Decision#d1

Range-partition the audits table by month on a time-sortable id, keeping 12 months in Postgres

Decision#d2

Archive audits older than 12 months to S3 with monthly reconciliation before removing them from Postgres

Decision#d3

Partition the existing table in place, attaching it as the first partition via a table-inheritance stepping stone

Decision#d4

Automate partition rotation with scheduled Rails jobs instead of pg_partman

Sign in to read what was chosen, what was rejected and what it cost, each with its place in the source. An account is free. The job-queue cards are open without one.