node-postgres on TechEmpower/FrameworkBenchmarks
https://github.com/TechEmpower/FrameworkBenchmarks is a poupular nodejs benchmark:
This project provides representative performance measures across a wide field of web application frameworks.
I have noticied that most of the frameworks use postgres.js probabily because it claim to be the faster postgres client (I have also discussed here https://github.com/brianc/node-postgres/issues/3391 )
My suggestion is to mantains the nodejs benchmark https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/JavaScript/nodejs and take it updated with last version an improve it with:
- pg-native
- prepared statement
The goal is promote pg is better!
Yeah the misinformation from postgres.js is pretty unfortunate. If anyone wants to do a benchmark between the two librarys and contribute it here I'm happy to pay them to do it. Please email me at [email protected]. I personally don't have interest in trying to "compete" with another open source project, felt pretty annoyed when that project came out w/ those benchmarks, and just don't want to engage. But it is probably important to get the truth out. For example, my friend works at a major cloud provider (cannot share name of company) and they switched from postgres.js to node-postgres on their backplane routing infrastructure and saw their throughput numbers DOUBLE and latency numbers be cut in half. Just goes to show marketing rules all. I am not sad there is another postgres driver for node, for sure, I just don't like the whole "the fastest ....bla bla" shit when its not that simple.
Done! An honest benchmark https://github.com/nigrosimone/postgres-benchmarks
summary
brianc/node-postgres (pg-native)
1.13x faster than brianc/node-postgres (pg)
1.25x faster than porsager/postgres (postgres)
My two cents
Both node-postgres and postgres,js are pretty close, no differece in real world. Just pg-native is a bit faster!
Running benchmarks... --iterations=50000
GC is exposed
Poll size: 10
Dependencies versions:
{
"pg": "^8.16.3",
"pg-native": "^3.5.2",
"postgres": "^3.4.7"
}
Database connectivity verified
clk: ~3.06 GHz
cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
runtime: node 24.7.0 (x64-linux)
benchmark avg (min … max) p75 / p99 (min … top 1%)
----------------------------------------------- -------------------------------
brianc/node-postgres (pg-native) 161.73 µs/iter 159.26 µs █
(113.45 µs … 1.01 ms) 391.13 µs █
( 6.93 kb … 2.07 mb) 11.93 kb ▁▄█▆▃▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁
brianc/node-postgres (pg) 183.02 µs/iter 197.19 µs █
(129.61 µs … 1.77 ms) 402.29 µs █▅▃
( 1.80 kb … 1.93 mb) 15.46 kb ▁███▆▅▅▄▃▃▂▂▂▂▁▁▁▁▁▁▁
porsager/postgres (postgres) 202.32 µs/iter 220.90 µs █
(140.51 µs … 1.22 ms) 436.25 µs █▆▄
( 4.90 kb … 1.10 mb) 13.97 kb ▁████▇▆▄▃▃▃▂▂▂▂▁▁▁▁▁▁
summary
brianc/node-postgres (pg-native)
1.13x faster than brianc/node-postgres (pg)
1.25x faster than porsager/postgres (postgres)
PS:
- https://github.com/brianc/node-postgres/pull/3511 in benchmark has a little performance improvements
- I have published a post https://dev.to/nigrosimone/benchmarking-postgresql-drivers-in-nodejs-node-postgres-vs-postgresjs-17kl