Postgres 18 Clones Let Each Git Worktree Agent Get Its Own Dev Database

Running several AI coding agents in separate git worktrees isolates their code but not a shared local Postgres database, so one agent's migration can break another's tests. The article proposes giving each worktree its own cloned database instead of a full server or a full data copy. Since Postgres 15 the default CREATE DATABASE strategy copies data block by block, while Postgres 18 adds a file_copy_method setting that can use copy-on-write filesystem cloning to make copies much cheaper. Using it requires setting file_copy_method to clone and specifying STRATEGY = FILE_COPY in the same session, since the default WAL_LOG strategy ignores that setting. The author cites benchmarks where cloning a 6,289 MB database took 212 ms instead of 67,000 ms.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in