The minipg demo runs a PostgreSQL instance inside the v86 emulator, accessed via a web‑based terminal.
*minipg collapses a full PostgreSQL stack into one portable binary. No server, no Docker, no VM—just a .pgdb directory that spins up on demand. The trade‑off: convenience versus a noticeable performance hit.*
Jeff Lindsay’s minipg redefines how developers interact with PostgreSQL. The tool bundles the official Docker Hub postgres:18‑alpine image and runs it through the h9 library, which presents a Plan 9 kernel to the Linux binaries. The result is a single executable that creates a .pgdb directory holding data, config, credentials, and the exact Postgres version. When a command needs a server, minipg launches one in the background and shuts it down the moment it goes idle. No separate daemon, no Docker daemon, no hypervisor boot‑up—just an on‑demand database that can be copied like any folder.
minipg embeds Docker Hub’s postgres:18‑alpine image and runs it with h9, a Zig library that supplies a Plan 9 kernel to answer Linux system calls. The .pgdb directory becomes the entire database: a minipg.toml file with settings and a generated superuser password, plus a pgdata subdirectory that mirrors PostgreSQL’s native data layout. On first launch, the image’s docker‑entrypoint.sh initializes the cluster; subsequent commands reuse the same lock‑enforced process. Each client tool—psql, pg_dump, etc.—spins up a short‑lived h9 machine (≈90 ms) that shares the same root, ensuring isolation without a full VM.
The demo, a 35 MB download, runs minipg’s Linux build inside the Postgres image itself via the v86 x86 emulator. It requires browsers that support JavaScript Promise Integration, available in Chrome and Edge from version 137; other browsers are catching up. Because a page cannot open TCP sockets, the demo serves PostgreSQL on a Unix socket. New databases are created from a template cluster baked at build time, sidestepping the half‑minute initdb delay on v86. The demo can also be opened on its own page, showing a terminal that launches psql directly.
On h9’s native backend, minipg runs PostgreSQL about twice as slow as a native installation for a single client, and the gap widens under load. The author warns against trusting the tool with data that cannot be recreated. The early‑stage nature of h9’s Linux personality means bugs are expected. Users are urged to report issues on GitHub and to avoid production workloads until the performance gap narrows and stability improves.
The source lives on GitHub under an MIT license. Building requires Zig 0.16 plus curl, jq, tar, and xz for the root image. Typical steps: clone the repo with submodules, run `make build` to pull the host‑specific root, then `make` to produce the static Linux binary. For other architectures, `make root ARCH=386` fetches the appropriate root; `make web` builds the demo page into .zig‑out/web. Once built, commands like `minipg init test.pgdb` and `minipg run test.pgdb -- go test ./...` enable CI pipelines without privileged devices. Bugs and questions are routed through the GitHub issues tracker.
A .pgdb directory stores minipg.toml (settings and generated superuser password) and pgdata, PostgreSQL's data directory as plain files, making the whole database portable.
Yes. The demo runs minipg's Linux build inside the Postgres image via the v86 emulator and requires browsers with JavaScript Promise Integration, such as Chrome and Edge version 137 or later.
No. The author warns that on h9's native backend PostgreSQL is about 2× slower than native and slower under load, and advises against using it for data that cannot be recreated.
minipg proves that a full‑featured relational database can live inside a single executable, a compelling proposition for CI and edge environments. Yet the current performance penalty and early‑stage stability mean it remains a developer curiosity rather than a production staple. As h9 matures, the gap may close, potentially reshaping how teams spin up databases on demand.
Sources: [Hacker News – Minipg: PostgreSQL as a Single Executable]