HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
peterldowns
pgtestdb
Go2023–2026
peterldowns / pgtestdb

pgtestdb

quickly run tests in their own temporary, isolated, postgres databases

4Distinct people
13Mentions
0Explicit recommenders
517GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

quickly run tests in their own temporary, isolated, postgres databases

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:03:16 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year13 dated mentions

Observed mentions: 2023-06-04 20:37:56 UTC to 2026-08-01 17:42:49 UTC.

024682023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20232024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 8 mentions; 0 submissions, 8 comments20242025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC312
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC808
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC101

What Hacker News says

13 sources
Really interesting article, I didn't know that the template cloning strategy was configurable. Huge fan of template cloning in general; I've used Neon to do it for "live" integration environments, and I have a golang project https://github.com/peterldowns/pgtestdb that uses templates to give you ~unit-test-speed integration tests that each get their own fully-schema-migrated Postgres database. Back in the day (2013?) I worked at a startup where the resident Linux guru had set up "instant" staging environment databases with btrfs. Really cool to see the same idea show up over and over with slightly different implementations. Speed and ease of cloning/testing is a real advantage for Postgres and Sqlite, I wish it were possible to do similar things with Clickhouse, Mysql, etc.
In Instant database clones with PostgreSQL 18
OK, that goal makes sense, thanks for explaining. For what it's worth I'm pretty sure you can do this with postgres, tmpfs, and template databases — see my project, pgtestdb [0]. I haven't done a formal perf measurement, but each test would get a fresh and migrated database in about 20ms on my local machine. The setup described runs postgres in a container for convenience, but you could probably also just run a postgres binary and store the data on a memory-backed filesystem. [0] https://github.com/peterldowns/pgtestdb
In Show HN: I open-sourced the in-memory PostgreSQL I built at work for E2E tests
Selfishly, I'd love a documentation review if you (or anyone else) has the time to take a try out some golang projects I've been working on. The code is frankly not very polished and not worth reviewing, but I'm curious to hear feedback on the documentation / README and whether or not you clearly understand what these libraries are for and how to use them. * https://github.com/peterldowns/pgtestdb * https://github.com/peterldowns/testy * https://github.com/peterldowns/pgmigrate
In Show HN: Goralim - a rate limiting pkg for Go to handle distributed workloads
This seems great but is actually quite slow. This will create a new container, with a new postgres server, and a new database in that server, for each test. You'll then need to run migrations in that database. This ends up being a huge pain in the ass. A better approach is to create a single postgres server one-time before running all of your tests. Then, create a template database on that server, and run your migrations on that template. Now, for each unit test, you can connect to the same server and create a new database from that template. This is not a pain in the ass and it is very fast: you run your migrations one time, and pay a ~20ms cost for each test to get its own database. I've implemented this for golang here — considering also implementing this for Django and for Typescript if there is enough interest. https://github.com/pet
Read the rest
In Testcontainers
Interesting idea to implement a proxy that does something on each new connection. I’ll have to think about that but very cool concept that lets this work for tests written in any language. Will each testcase need to run migrations after connecting for the first time? Also, I’m used to using clients which lazily pool connections, do they still work with this model? Op, I’d be curious what you think of my project pgtestdb, which takes a different approach: use a single server, but create new databases each time. Maybe there is some middle ground where a proxy creates a new cloned db after each connection? https://github.com/peterldowns/pgtestdb
In Pgtemp: The easiest way to write tests with Postgres in Rust, without Docker
Agreed with most of this but I’m skeptical of the rsc.io/script dsl approach. I’ll try it, though, because Russ is often right. shameless advert: do you wish testify was implemented with generics and go-cmp, and had a more understandable surface area? Check out my small library, testy https://github.com/peterldowns/testy shameless advert: do you want to write tests against your postgres database, but each new test adds seconds to your test suite? Check out pgtestdb, the marginal cost of each test is measured in tens of milliseconds, and each test gets a unique and isolated postgres instance — with all your migrations applied. https://github.com/peterldowns/pgtestdb
In Go Testing by Example [video]

Show HN: Pgtestdb, fast Postgres dbs for Golang tests

Hi HN, I'd like to get your feedback on pgtestdb, a new library for helping you write more useful database-backed tests. Many applications rely heavily on their database — and why shouldn't they! But writing tests that use the database is always a bit awkward, or in the worst case, very slow. Sometimes teams even mock their database out for an in-memory one, which works but only as long as you're not relying on specific features of your database. Postgres is a fantastic database, and at my last job we relied heavily on its views, functions, data types, etc. A lot of our application logic was tied up with it. But writing tests against it was slow. Naively, each test would have to: - Create a new database - Run our migrations on it - Then run the test - Then tear down the database pgtestdb makes this all a lot faster with two major strategi
Read the rest
es: - Use a ram-backed or tmpfs-backed server that drops all data consistency guarantees. This isn't an issue for tests at all, and makes them much faster. - Use template databases to only ever have to run the migrations once, when they change, and then fork that template each time a test asks for a new database. Check out the docs on the Github page for more information but I hope you find this useful. I've written adaptors for most common migration frameworks so hopefully you can try it out without much issue. Sincerely, Peter
4 points · Open discussion
Hi Weston, congratulations on launching. You've done a great job of explaining what the project is and how it works. I'm not in the ecosystem you've built this for so I can't comment too much on the project itself, but nice work communicating it. EDIT: after reading through the linked docs a bit more, I have to say that they are quite confusing. I'm not sure what the difference is between Ratifier, Kulvert, and SQL Simulator. I'd recommend finding a potential user and watching them go through the setup/install process and see where they have questions. If anyone is interested in something similar for postgres, I recently released https://github.com/peterldowns/pgtestdb. It uses template databases and advisory locks to give each test its own unique database with a near-zero marginal cost for each additional test. Combined with a ram/tmpfs-
Read the rest
backed postgres server that is tuned for performance, it goes extremely fast. Currently just for golang but I'm planning on releasing equivalent-capability libraries for Python and Typescript over the next month. If anyone has any thoughts/comments/feedback/suggestions I'd be extremely thankful.
In Show HN: SQL Dry Runs with SQL Simulator

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.