Anyone also experiencing this issue?

Hey community, I started using drizzle for quering against my PostgreSQL for a project and noticed a HUUUUUGE query time that I did not expect. My observations can be found here: https://github.com/drizzle-team/drizzle-orm/issues/3001 Do you guys experience the same weird behavior with different versions of the pg module?
GitHub
[BUG]: Horrible query performance · Issue #3001 · drizzle-team/driz...
What version of drizzle-orm are you using? 0.33.0 What version of drizzle-kit are you using? 0.24.2 Describe the Bug I am trying to run a simple aggregation query to count the existence of a record...
5 Replies
Kuba
Kuba•2mo ago
Since you're using prepared statements, shoudn't you start console.time just before
const existsResult = await existsPrepared.execute({id})
const existsResult = await existsPrepared.execute({id})
? I haven't used prepared statements myself, but I would guess that creating a statement and executing it are two different things, and the former might take longer, thus your execution takes circa 40ms
François
FrançoisOP•2mo ago
Thats what I thought at first too but even starting the timer right before the execute call results in this slow performance. Digging deeper into the code I found out that the problem is the pg driver. From version 8.2.0 upwards the performance is as bad as it is in my example. Using 8.1.0 results in the same times. Its not surprising per se, bugs happen but I am suprised being the only one noticing this. Drizzle doesnt put together the query string itself. It calls a method of the pg driver passing a configuration object, that hols the query with the placeholders + an array with the values for the placeholders. The driver then puts together the query. Actuall its the query call I had in my benchmarking code, just with the different parameters. Comparing those two calls, the one with the direct query string and the config+parameters, results in the differences I see when using drizzle. The last version there was no difference was 8.1.0. 8.2.0 introduced a new parser which might be the problem. But still: Why am I the only one experienceing this issue 😄
François
FrançoisOP•2mo ago
So the only fix I see now is downgrading the pg driver to 8.1.0 and hope for a fix on their site. I already opened an issue in their repo: https://github.com/brianc/node-postgres/issues/3325
GitHub
Horrible query performance since 8.2.0+ · Issue #3325 · brianc/node...
I was trying out drizzle, using a PostgreSQL database (v15). I experience a huge performance issue just querying one row of a table with just one row. So I dig a little deeper inside the code and f...
François
FrançoisOP•2mo ago
Wish I would have enough time to further dig deeper into their code and actually fix it but life....
Kuba
Kuba•2mo ago
That's actually good spot! I was thinking lately about integrating prepared statements myself, but if it results in performance drop, then I might subscribe to these issues for a bit
Want results from more Discord servers?
Add your server