PostgreSQL 18 clones a 6 GB database in 212 milliseconds with file_copy_method = clone, but CREATE DATABASE refuses to run while even one idle session is connected to the source. So I patched the check out. Every clone came out fine, which proved less than it looked like. The check is really about writes: commit status lives in the cluster-wide pg_xact, so a transaction that commits after the copy shows up in the clone too.

Copying a database that keeps writing takes the whole cluster, and a second Postgres that comes up through crash recovery. Running one per pull request is mostly about everything around the copy: 351 lines of scripts around a single zfs clone.

Continue reading on boringsql.com (15 min)