Live data from Hacker News

Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

github.com

21–30 of 87 posts

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#22
post #21

How can this be so much faster than even pg-native that uses the C library libpq? https://github.com/porsager/postgres-benchmarks#results

It leverages pipelining and implicitly creates prepared statements.

And I've spent quite some time optimizing the js code and parsing.

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#23
post #2

Hi everyone. A bit more than two years ago I released the first version of Postgres.js. A fully featured PostgreSQL driver for Node.js written as a learning experience out of curiosity and annoyance with the current options. It greatly outperformed the alternatives[1] using pipelining and prepared statements, while providing a much better development experience safe from SQL injections. Since then I've been busy buil…

Super cool, looks great. Interesting to see you built it with Typescript.

I was wondering-- and I know this is a long story, but I am curious:

How does one go about building a PostgreSQL driver for NodeJS in Typescript?

How do you design and begin that sort of thing? What sort of knowledge resources did you rely on (i.e. documentation, other references)?

I googled 'database driver' to get a definition: "A database driver is a computer program that implements a protocol (ODBC or JDBC) for a database connection. The driver works like an adaptor which connects a generic interface to a specific database vendor implementation."

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#24
post #21

How can this be so much faster than even pg-native that uses the C library libpq? https://github.com/porsager/postgres-benchmarks#results

> How can this be so much faster than even pg-native that uses the C library libpq?

the c++ to javascript membrane in v8 is expensive to pass. there are many projects that are faster implementing protocols in javascript vs c/c++ because of this.

redis is another.

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#25

Very cool! Would you consider this production ready ? I rarely if ever use relational databases for my personal projects, but this could be a great fit at work. Also , anyway to add an orm layer. I use Firebase right now, so I'm use to that vs writing queries.

Thanks. Definitely production ready, and I've been using it for quite a while in production myself, towards this release. About the ORM layer I wouldn't know, since I much prefer to avoid that at any cost.

Ok, I'd have to double check to see if the Unlicense is ok for work projects, but this is a great contribution to the node ecosystem.

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#26
post #21

How can this be so much faster than even pg-native that uses the C library libpq? https://github.com/porsager/postgres-benchmarks#results

It leverages pipelining and implicitly creates prepared statements. And I've spent quite some time optimizing the js code and parsing.

Do MySQL!

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#28
I spent some time today trying to replace pg but I ran into an issue. When using an rds proxy with iam authentication, it seems to repeatedly retry authentication and eventually my lambda functions time out. If I switch to using regular credentials it works fine. Using the exact same options with pg+iam authentication also works fine which leads me to believe it's an issue with this project.

I'll open an issue on GitHub tomorrow.

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#29

Earlier quoted context omitted.

It leverages pipelining and implicitly creates prepared statements. And I've spent quite some time optimizing the js code and parsing.

Do MySQL!

Why not give it a try yourself? Building a database library is an educational project, and you can give back if it turns out to be a quality one, too.

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#30
post #21

How can this be so much faster than even pg-native that uses the C library libpq? https://github.com/porsager/postgres-benchmarks#results

> How can this be so much faster than even pg-native that uses the C library libpq? the c++ to javascript membrane in v8 is expensive to pass. there are many projects that are faster implementing protocols in javascript vs c/c++ because of this. redis is another.

This can’t be overstated. Crossing the JSnative barrier is inherently a perf hit. I’ve measured it trying a large variety of high performance messaging protocols and postMessage with structured clone nearly always wins. If that sounds like a bold claim, there are troves of Node and Deno issues where they’ve improved perf by staying in JS specifically because calling into native and back has been the bottleneck. There are countless similar issues in V8 and WebKit as well.

You can get a perf boost with WASM or NAPI, but only for workloads which are CPU bound and where you expect to do that work in compiled code.

Post reply on HN