porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.26k stars 262 forks source link

Support for Bun #681

Closed AshwinTayson closed 11 months ago

AshwinTayson commented 11 months ago

Since Bun has released 1.0, it is a stable and beating node and deno in alot of benchmarks. Would there be support for Bun runtime in the horizon like Deno?

leeoniya commented 11 months ago

Bun aims to be a drop-in Node replacement, so in theory there shouldnt be anything needed from libs. the question is what does Bun need to still do to support this lib, if anything.

AshwinTayson commented 11 months ago

For the most part this is true, but to take full advantage of Bun's runtime, if there are any apis from native Node being used they should be changed to Bun APIs.

porsager commented 11 months ago

Postgres.js has worked with bun since Bun v0.5 https://bun.sh/blog/bun-v0.5.0 and is the recommended PostgreSQL driver. What made you think it shouldn't work?

porsager commented 11 months ago

Sorry, responded to first post 😊 Wrt. performance, bun was already faster back then in the few quick tests i did. (like 10-20%)

I don't think using the native bun APIs would change much, I'd much rather implement Postgres.js in zig for bun then, but there's a good chance @Jarred-Sumner might beat me to it 😋

AshwinTayson commented 11 months ago

@porsager I didn't test it. Since there's drop in support for Node I knew it would work, but the performance boost is what I was looking for. I've seen some packages were Node packages were replaced with Bun's and there were 20-40% improvement other than the runtime speed.

About your comment on Postgres.js implementation in Zig. I see this library is completely in JS. Does that mean if this is re-written in a native (low-level) language, it will have a better performance? Or this library is like a wrapper to native libraries like libpq

hastebrot commented 11 months ago

Does that mean if this is re-written in a native (low-level) language, it will have a better performance? Or this library is like a wrapper to native libraries like libpq

Maybe.

On Bun's roadmap is "Fastest PostgreSQL client available in JavaScript" and they also want to explore a libpq-based implementation.

Right now, you could just use this library on node, bun, or deno to implement an ecommerce platform with a million products and thousands of users, and performance will be just fine, I ensure you.

porsager commented 11 months ago

@AshwinTayson Both approaches should be investigated, but not something I want to track at the moment ;)