porsager / postgres-benchmarks

A set of benchmarks focusing on the performance of Postgres client libraries for Node.js
87 stars 6 forks source link

Ran benchmarks #7

Open xerosanyam opened 2 years ago

xerosanyam commented 2 years ago

Benchmarks ⚡️

postgres@1.0.2, slonik@23.5.5

image

postgres@3.2.4, slonik@28.1.1

image

postgres@3.2.4, slonik@28.1.1 with max=1 (as suggested in slonik benchmark)

image

also ran the suite provided in slonik. here are the results - https://github.com/gajus/slonik/issues/352

porsager commented 2 years ago

Cool. The benchmarks in the slonik repo are absolutely useless. They measure serial query performance which doesn't make any sense. You don't want to queue up all queries in a line and await each one before responding to the next 🙈

You can also see the Imdbench benchmarks i recently added Postgres.js to, and see that it is actually the fastest client against python and go. (and much faster than pg which as you know slonik is based on)

https://porsager.github.io/imdbench/sql.html

gajus commented 2 years ago

Since Slonik is an abstraction around pg, Slonik is not going to be faster than pg.

The original intent of having those benchmarks (before postgres) was just to demonstrate that Slonik does not add/adds little overhead to pg.

They measure serial query performance which doesn't make any sense. You don't want to queue up all queries in a line and await each one before responding to the next 🙈

That's an accurate representation of any data processing application. Data is going to be ingested sequentially.

What's your idea of a fair comparison?

Regardless, there is an open issue for Slonik to support postgres as an alternative driver.

gajus commented 2 years ago

Compatibility layer released in https://github.com/gajus/postgres-bridge

gajus commented 2 years ago

That said, the performance is horrendous, and that's because (I think) postgres doesn't allow explicit connection pool managing. This means we need to initialize postgres({max: 1}) for every connection.

gajus commented 2 years ago

Actually, it is not as bad as I thought the first time I tested. Seems to have minimal overhead.

https://github.com/gajus/postgres-bridge#benchmark

xerosanyam commented 2 years ago

Thank you for the great work @gajus!