← Back to Tech Radar
Hacker News tech

Pgtestdb's template cloning approach to testing is fast

Trending on Hacker News: Pgtestdb's template cloning approach to testing is fast (54 points / 34 comments, via brandur.org)

In one line

Postgres database templates make pgtestdb’s per-test database isolation remarkably quick, around 100 ms of setup time, and within spitting distance of River’s schema-based approach.

Opening excerpt

Auto pgtestdb’s template cloning approach to testing is fast Fragment 🔗 pgtestdb’s template cloning approach to testing is fast Published Jul 29, 2026 I’m on X/Twitter at @brandur .

I was reminded by Cup o’ Go yesterday of the existence of Peter Downs’ pgtestdb , a Go/Postgres testing package.

pgtestdb is built around Postgres template databases , a built-in feature that you can try right from a vanilla psql shell:

CREATE DATABASE dbname TEMPLATE template_to_copy; Copying a template is very fast, more so than migrating a test database from scratch, and much more so than some of the heavyweight Docker-based techniques some projects are using these days. At a low level, Postgres enumerates the template’s relations and copies their materialized heap, index, and catalog files in 8 kB page chunks.

(Excerpted from the original; full article via the source link below.)

This story hit the Hacker News front page today (54 points / 34 comments, via brandur.org). Our Tech Radar aggregates daily signals on AI engineering, backend architecture and DevOps — browse the related services and further reading below, or get in touch with our team.

Source: Hacker News

Related Services

Related Reading