0

I have two independent queries for example:

const query = "SELECT PG_SLEEP(30);"
const query1 = "SELECT PG_SLEEP(30);"

console.time("Query")
await Promise.all([pgClient.query(query), pgClient.query(query1)]);
console.timeEnd("Query")

This, according to the documentation, will be added to a queue and execute one after the other, is it possible to execute the two queries asynchronously? so the registered time should be around 30 instead of 60...

UPDATE: Other approach would be to use the pool feature of the library instead of instantiating two clients

1 Answer 1

1

For that, you have to open two database connections. Then it is no problem to have two queries running concurrently.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeap that works too, I thought there's a way w/o using that approach
No, that is the only way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.