4 ms·
I uploaded most of our Workspace setup here: https://github.com/jschaf/bazel-postgres-sketch https://github.com/jschaf/bazel-postgres-sketch. The tooling is a b
by sa46 5y ago
I uploaded most of our Workspace setup here: https://github.com/jschaf/bazel-postgres-sketch https://github.com/jschaf/bazel-postgres-sketch. The tooling is a bunch of Go to manage the Postgres process. Basically, give it schema files and receive a running database with a tear down command.
We make temp instances of Postgres quickly by:
- avoiding Docker, especially on Mac
- keeping the data dir on tmpfs
- Disable initdb cleanup
- Disable fsync and other data integrity flags
- Use unlogged tables.
- Use sockets instead of TCP localhost.
For a test suite, it was 12x faster to call createdb with the same Postgres cluster for each test than than to create a whole new db cluster. The trick was to create a template database after loading the schema and use that for each createdb call.
- jvolkman 5y agoCool, thanks for the link. For what it's worth, we use rules_nixpkgs to source Postgres (for Linux and Darwin) as well as things such as C and Python toolchains, and it's been working really well. It does require that the machine have Nix installed, though, but that opens up access to Nix's wide array of prebuilt packages. https://github.com/tweag/rules_nixpkgs https://github.com/tweag/rules_nixpkgs