Open xerosanyam opened 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)
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.
Compatibility layer released in https://github.com/gajus/postgres-bridge
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.
Actually, it is not as bad as I thought the first time I tested. Seems to have minimal overhead.
Thank you for the great work @gajus!
Benchmarks ⚡️
postgres@1.0.2, slonik@23.5.5
postgres@3.2.4, slonik@28.1.1
postgres@3.2.4, slonik@28.1.1 with
max=1
(as suggested in slonik benchmark)also ran the suite provided in slonik. here are the results - https://github.com/gajus/slonik/issues/352