TLTR: pg-native wins
When building high-performance Node.js applications with PostgreSQL, choosing the right driver can have a noticeable impact on query latency and throughput. To compare the most popular options, we ran a benchmark using mitata to test three libraries:
- pg-native by brianc/node-postgres (C library bindings)
- pg (AKA node-postgres) by brianc/node-postgres (standard JavaScript implementation)
- postgres (AKA postgres.js) by porsager/postgres (standard JavaScript implementation)
Source code at https://github.com/nigrosimone/postgres-benchmarks
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)
pg-native wins
The pg-native driver leverages libpq, the official PostgreSQL C client library. This allows faster query parsing, lower overhead on network I/O, and better memory handling than the pure JavaScript implementation. Essentially, pg-native
skips part of the JS-to-database abstraction cost.
pg is close behind
Despite being pure JavaScript, pg (AKA node-postgres) remains very efficient and stable. The performance gap is small and might not be noticeable in real-world apps unless you're processing tens of thousands of queries per second.
Conclusion
For high-throughput Node.js applications where microseconds matter, pg-native consistently outperforms both pg (AKA node-postgres) and postgres (AKA postgres.js). However, the difference isn’t massive — your choice should balance performance, API design, and operational complexity.
Top comments (0)