-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nodejs v18.17.1 / v20.9.0 - pg ^8.11.0 - slow select query #3098
Comments
Cannot reproduce it on different machines,except windows 11 for unknown reasons |
Very strange! Sounds like more of an issue w/ something internal to node on v18/20 on windows. Please lmk if you track down what it is! |
Found this when troubleshooting my ORM problems. Indeed, for me on Windows 11 and with Postgres running in a Docker container in WSL, basic queries on node 16 take like 2ms, and on node 22 - 40ms. Specifically, I get these results when running Kysely and Drizzle ORM with pg driver. Though there are caveats.
|
do raw queries executed through this library w/o an orm wrapper take a long time? only on windows w/ node 22? 🤔 |
Should've checked it before, I guess. When raw queries are fired from Kysely and Drizzle ORM are slow on nodes 22, 20, 18, (I only have Windows 11 machines) and are sufficiently fast on 16. (I didn't check the odd-numbered ones) But since |
it could have something to do w/ not using a pool or something internally. not sure, but I know it takes orders of magnittude longer to connect & handshake w/ postgres than to do a query (hence we all use connection pools) so maybe they aren't? Really no idea, but I'm glad to know the speed issue is w/ a 3rd party lib and not this one! 😅 |
Ok, I actually reproduced the issue on node-postgres. The issue is with parameterized queries. The library is fast when it fires just raw strings, but is slow when using parameters like $1, $2, etc. |
I am using the following query to retrieve users from database, and before this one i just perform a count(*) to retrieve the total number of users.
The execution with nodejs v18.17.1 / v20.9.0 - pg ^8.11.0 results to something between 60 and 92 ms for both count and the query mentioned above, but the same process with nodejs v16.20.2 results to 12ms for both queries (average).
Are there any issues with node-postgres and nodejs versions > 16? Am I missing something?
The text was updated successfully, but these errors were encountered: