r/SQL • • 2d ago

PostgreSQL Self-hosted alternative to Neon's HTTP driver: query your own Postgres via fetch()

/r/postgres/comments/1y3qrfx/selfhosted_alternative_to_neons_http_driver_query/
0 Upvotes

4 comments sorted by

1

u/Discordbothost 1d ago

The Idempotency-Key example covers a lost 202. I'd add one for an unknown commit too. Insert a unique operation ID in the same transaction as the write, then check Postgres for that ID. Reuse it if you retry, so both attempts can't commit.

1

u/Savings-Feedback6581 1d ago

i would surely add it thanks

1

u/MongooseWonderful198 1d ago

Cloudflare Workers can open outbound TCP connections through cloudflare:sockets. Hyperdrive also supports existing PostgreSQL servers, including self-hosted ones; it isn't limited to Neon. Private databases have supported connection paths too.

That changes the Cloudflare part of the comparison: the choice includes a Cloudflare-managed connection pool versus your self-hosted gateway with a portable fetch interface. The latter can still be useful across runtimes, but saying Workers can't open TCP hides an option readers may already have. Keeping that distinction explicit would make the deployment comparison more useful.

1

u/Savings-Feedback6581 1d ago edited 1d ago

yes they can handle it my mistake but the issue is time taken by tcp rather than just a fetch to retrieve and update data it saves the cpu time and yes you can use hyperdrive but i guess it is capped at 25 connections

For long-running joins, you can also receive a query ID and fetch the results later instead of keeping your serverless function running.