Pgtestdb's template cloning approach to testing is fast

This database test trick is weirdly fast, and commenters are low-key obsessed

TLDR: A tool that copies a ready-to-go database for testing turned out to be almost as fast as a highly optimized custom setup, which surprised even the author. In the comments, users cheered the real-world usefulness while the tool’s creator celebrated the result like an underdog finally getting respect.

A niche coding experiment somehow turned into a mini victory lap in the comments. The big reveal: pgtestdb, a tool that makes copies of a ready-made PostgreSQL database for tests, turned out to be shockingly quick — roughly the same setup speed as the author’s carefully tuned in-house method. For people outside the developer bubble, that means a boring behind-the-scenes step that usually eats time suddenly got a lot less painful. And yes, the crowd immediately pounced on the real takeaway: wait, you can just clone the whole thing and it’s still fast?

The strongest reaction wasn’t outrage — it was a mix of surprise, admiration, and that classic internet energy of “I knew this was useful!” One commenter, lukasschwab, basically showed up as living proof that the tool is already helping real people learn River by building tiny apps and testing them end to end. That gave the whole thread a wholesome flex. Then pgtestdb creator peterldowns jumped in with pure sportsmanship, praising the rival setup as a “gold standard” while also sounding delighted that his own package can get nearly the same speed out of the box.

The only real drama? The numbers had a twist. While the clone trick was fast to start, the older method still won the full test-suite marathon by reusing work behind the scenes. So the vibe in the comments wasn’t “old way dead,” but more like “wow, the new kid is scary good already.” Nerdy? Absolutely. But the comment section treated it like an underdog story with benchmark receipts.

Key Points

  • The article evaluates pgtestdb, a Go/Postgres testing package that uses PostgreSQL template databases to clone test databases quickly.
  • PostgreSQL template cloning works through `CREATE DATABASE ... TEMPLATE ...` and copies database files such as heap, index, and catalog data in 8 kB page chunks.
  • Benchmark results showed similar setup times for pgtestdb cloning and River’s create-and-migrate schema approach, both at roughly 100 ms on average.
  • Despite similar setup time, overall suite runtime was much faster for River’s schema-based method: 14.54 seconds versus 51.07 seconds for pgtestdb cloning.
  • The article attributes River’s faster full-suite performance to pooling and reusing test schemas, and suggests similar reuse could be added to pgtestdb.

Hottest takes

"That’s exactly what I did to learn River" — lukasschwab
"he's understating it when he says their implementation is 'gold standard'" — peterldowns
"surprised and excited to hear that pgtestdb, out of the box, can give anyone a ~nearly as fast experience" — peterldowns
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.