It appears that a `Promise.all()` of "pg" requests happens serially rather than parallel. Expected?

Hi there, I'm using the pg package inside a cloudflare worker. It's connected via a socket to a Neon database. I'm executing about 100 requests in parallel to the database (inside a Promise.all() wrapper) but it appears as though the requests are resolving sequentially rather than in parallel (which makes the query take a lot longer than expected). Is this expected behavior? It's always possible that something else is going on with my code, but I want to quickly double check the behavior of Cloudflare Workers.
1 Reply
Zeri
ZeriOP14mo ago
Oh wow. It looks like individual postgres connections don't support concurrency. I've used postgres off-and-on for several years now, I can't believe I didn't know this. I guess all the tools I've used in the past have abstracted away from this limitation. So the behavior I'm seeing is the result of using a single database connection to process an array of queries. Postgres will only resolve the queries in sequence and not in parallel.
Database Administrators Stack Exchange
Are postgres connection able to manage multiple requests at the sam...
I have an application using node Postgres driver to connect to my Postgres 12. The pool size is currently 1. Is it possible, for one connection, to have multiple requests sent before receiving the
Want results from more Discord servers?
Add your server