# Layout and Snapshots

## Jail

- jail name: `db`
- hostname: `db.clawdie.si`
- IP: `192.168.100.10`
- role: persistent database service
- provisioning: `thick`

## ZFS expectations

PostgreSQL on ZFS has two different tuning layers:

1. pool/vdev sector alignment
2. dataset-level properties

### Pool/vdev alignment

`ashift` belongs to the pool/vdev layer, not the dataset.

Important:

- it should match the real sector size of the underlying device
- for modern 4 KiB devices, that usually means `ashift=12`
- it cannot be changed later on an existing pool/vdev

Validate the real pool before assuming PostgreSQL storage is correct.

### Dataset-level tuning

Conservative starting properties for PostgreSQL data:

- `compression=lz4`
- `atime=off`
- `recordsize=16K`

Why `recordsize=16K`:

- OpenZFS explicitly calls out `recordsize` for database workloads
- PostgreSQL uses 8 KiB pages by default
- `16K` is a conservative starting point that stays near PostgreSQL access patterns and avoids the default `128K` record size

Treat `16K` as an initial operational default. Revisit it with benchmarks later.

The jail dataset should be snapshotted at these points:

1. after clean jail creation
2. after PostgreSQL 18 is installed and starts
3. before schema migration
4. before enabling `pgvector`

## Suggested snapshot names

- `@fresh`
- `@postgres18-ready`
- `@pre-schema`
- `@pre-pgvector`

## Design note

SQLite remains the current operational state store.

This PostgreSQL jail starts as the future long-term memory backend.
