Live data from Hacker News

PGlite – Embeddable Postgres

pglite.dev

71–80 of 118 posts

Re: PGlite – Embeddable Postgres

#71
post #70

Earlier quoted context omitted.

Does pglite in memory outperform “normal” postgres? If so then supporting the network protocol so it could be run in CI for non-JS languages could be really cool

for CI you can already use postgresql with "eat-my-data" library ? I don't know if there's more official image , but in my company we're using https://github.com/allan-simon/postgres-eatmydata

You can just set fsync=off if you don't want to flush to disk and are ok with corruption in case of a OS/hw level crash.

Re: PGlite – Embeddable Postgres

#73
PGlite is fantastic. I use it for my in-browser PostgreSQL server for development. It implements the PG protocol on the server; when clients connect, we forward queries to the user's browser, which runs PGlite under the hood.

The result is a PG server that fully lives in your browser: https://dbfor.dev

Re: PGlite – Embeddable Postgres

#74
post #68

Earlier quoted context omitted.

huh. could you tell how you use it in ci?

I'm using it for a service that has DB dependencies. Instead of using SQLite in tests and PG in production, or spinning up a Postgres container, you use Postgres via pglite. In my case, the focus is on DX ie faster tests. I load shared database from `pglite-schema.tgz` (~1040ms) instead of running migrations from a fresh DB and then use transaction rollback isolation (~10ms per test). This is a lot faster and more co…

Thank you for the details. This makes a lot of sense!

Re: PGlite – Embeddable Postgres

#75
post #32

This looks impressive. Could someone familiar with Postgres internals explain the hidden trade-offs of this approach? I understand the obvious limitations of it being embedded/single-host, but I'm curious about the engine itself. Does running in this environment compromise standard features like ACID compliance, parallel query execution, or the ecosystem of tools/extensions we usually rely on?

The key limitation (at the moment) is that it only supports a single connection. W're planning to lift that limitation though.

This is what I'm most interested in. I have an application which has a smaller trimmed down client version but it shares a lot of code with the larger full version of itself. Part of that code is query logic and it's very dependent on multiple connections and even the simplest transactions on it will deadlock without multiple connections. Right now if one wants to use the Postgres option, it needs Postgres manually installed and connected to it which is a mess. It would be the dream to have a way to easily ship Postgres in a small to medium sized app in a enterprise-Windows-sysadmin-friendly way and be able to use the same Postgres queries.

Re: PGlite – Embeddable Postgres

#76

Hey everyone, I work on PGlite. Excited to see this on HN again. If you have any questions I'll be sure to answer them. We recently crossed a massive usage milestone with over 3M weekly downloads (we're nearly at 4M!) - see https://www.npmjs.com/package/@electric-sql/pglite While we originally built this for embedding into web apps, we have seen enormous growth in devtools and developer environments - both Google Fir…

I see you guys are working on supporting the postgis extension. This would be HUGE!!! The gis community would be all over this.

If anyone wants to help out who has compiled the postgis extension and is familiar with WASM. You can help out here. https://github.com/electric-sql/pglite/pull/807

Re: PGlite – Embeddable Postgres

#77

Very neat. Impressive performance: https://pglite.dev/benchmarks Even has Drizzle ORM integration: https://orm.drizzle.team/docs/connect-pglite I will explore this for use in my unit / integration tests. It looks pretty amazing. I am confused why all my recent compiled tooling (tsgo, biomejs) are shipping native binaries (thus creating multiple binaries, one per supported platform) and not WASM tools that can run cro…

people want their programs to go as fast as possible, WASM can be better than writing JS but it’s not as fast as actually native code by a wide margin, especially if you want to do io

Re: PGlite – Embeddable Postgres

#79
For unit testing, I still use TestContainers which spins a full Postgres in Docker. But new alternatives like this make py-pglite (https://github.com/wey-gu/py-pglite) possible which is Python unit testing with PGlite. Even so, for Python unit testing I'm more confident in something like pgserver (https://github.com/orm011/pgserver) which offers the full, real Postgres in a lightweight pip package. Note: my take is specifically for unit testing, not other use cases!

Re: PGlite – Embeddable Postgres

#80

For unit testing, I still use TestContainers which spins a full Postgres in Docker. But new alternatives like this make py-pglite ( https://github.com/wey-gu/py-pglite ) possible which is Python unit testing with PGlite. Even so, for Python unit testing I'm more confident in something like pgserver ( https://github.com/orm011/pgserver ) which offers the full, real Postgres in a lightweight pip package. Note: my take…

What are the trade-offs you’ve seen between the two? Always appreciate this sort of experience report on HN!
Post reply on HN