Where should an append-only history of everything that happened go?
Applications like this: audit trails, activity history, event sourcing, compliance records. This page is written the way I write a database design doc: the workload first, then where each kind of data goes and why, then how it grows, what breaks, and what I rejected.
| Dimension | This application |
|---|---|
| Writes | Steady. One row per action. |
| Reads | Rare: investigations, compliance exports, a user's activity page. |
| Read to write | Very low. |
| Consistency | The entry must be committed with the action it records. |
| Latency | Writes must be cheap. Reads can be slow. |
| Growth | Forever, often by law. |
These incidents are why the choices below matter. Each one is written up with its numbers and sources.
Solid arrows: the application writes there. Dashed arrows: a copy fed from the source of truth (change data capture, an outbox, or a cache fill), which can be rebuilt from it.
| Data | Where it goes | Why |
|---|---|---|
| Recent history | A partitioned table in the same database as the action | Written in the same transaction, so an action never happens without its record. |
| Old history | Object storage in Parquet, or a column store | Cheap, and still queryable by analytics tools. |
| Event streams for other services | Kafka or a similar log | Other systems consume the events without querying your database. |
How each family of store behaves under traffic: Database families.
CREATE TABLE audit_log ( id bigint GENERATED ALWAYS AS IDENTITY, at timestamptz NOT NULL DEFAULT now(), actor_id bigint NOT NULL, action text NOT NULL, target text NOT NULL, details jsonb, PRIMARY KEY (at, id) ) PARTITION BY RANGE (at); REVOKE UPDATE, DELETE, TRUNCATE ON audit_log FROM app_user;
Pick a stage, then throw something at it. The numbers are a model to show the shape of each change, not a measurement; the measured numbers are in the lab notebooks.
| What happens | What you see | What I do |
|---|---|---|
| Audit written after the transaction commits | Actions with no record when the process crashes in between | Write it in the same transaction, or use the outbox pattern. |
| One giant unpartitioned table | Backups and vacuum take hours | Partition by time. |
| Personal data in the log | A deletion request you cannot honor | Store references, not personal data, or plan how to redact. |
Cost. Keep months online, years in object storage. The online part should be the smallest.
| Stage | Where it runs |
|---|---|
| Where I would start | In the same managed database as the action |
| When it grows | Old partitions exported to object storage |
For a team without a dedicated database team. Who does which job in each option, and the full-cost comparison: Where to run the database.
The back-of-the-envelope numbers I would want before choosing anything. Move the assumptions to match your application. The link keeps your numbers, so a colleague sees the same ones.
Which database does my application need? What kind of application data goes in which database, and why, as design docs, plus the anti-patterns and the decisions behind them.