nodejs + postgresql way too slow
See original GitHub issueI’m not sure whether this is an issue with pg
or not, but I am not being able to get a reasonably enough fast app using node-postgres (pg). I wrote a question on stackoverflow but it seems nobody was able to help me.
Here is the post on stack overflow. I thought it would be better just to link it instead of duplicating everything here. (Just tell me in case it would be better to have the full problem described here)
Thanks in advance for any help.
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
node.js - nodejs + postgresql way too slow - Stack Overflow
When I run apache bench on it, it get only about four requests per second. If I run the same query in php/apache...
Read more >[Node] Slow queries for PostgreSQL on NodeJS agent
Hello! I recently implemented the New Relic agent in my application, and would like to get more information about SQL queries that are...
Read more >This is why your Node.js application is slow
The simple problem with it is that it is capable of slowing down your application greatly when not correctly used. Whenever a promise...
Read more >Optimizing PostgreSQL query performance - Prisma
The first thing you should do is verify the current state of slow query logging. If slow query logging is already enabled, you...
Read more >Node = Slow? : r/node - Reddit
Most back end stuff is high latency - fetch from disk or SQL database, for example. In those cases, it doesn't matter that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
First thing I can see is you’re still running the query twice on every request. Remove all that stuff about the
QueryStream
and just callres.send(result.rows)
directly. There’s no reason to go through the hoops of streaming results to the client if there are only 1,000 rows. Possibly after 10k rows you’ll start seeing an advantage to streaming, but for the most part it only becomes apparent when you’re moving massive amounts of data. In your example you’re still selecting the entire 1,000 row result set into memory, disregarding it, and then doing the query a 2nd time and streaming the results to the client.All right. I’ll keep your recommendation in mind in my next attempts to understand what is going on. Thanks a lot for your help and time. I really appreciate it.