parallelity of queries (multiple queries at once)?
See original GitHub issueI wrote a program, which requests n-queries (for instance 20,000) at once to my postgres database.
When I do this with several clients who want to query 20,000 at once too, there is no parallelity. That means, the requests of the second client will be queued until the first client finished all his queries.
Is this a normal behavior for postgres? If yes, how can I prevent that one user gets all the ressources (and the others have to wait) if there is no parallelity?
This is my code:
const express = require('express');
const app = express();
const { Pool } = require("pg");
const pool = new Pool();
benchmark(){
pool.connect((err, client, done) => {
if (err) throw err;
client.query("SELECT * from member where m_id = $1", [1], (err, res) => {
done();
if (err) {
console.log(err.stack);
} else {
console.log(res.rows[0]);
}
});
});
}
app.get('/', function(req, res) {
for(let i=0;i<20000;i++){
benchmark();
}
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
Parallel Queries | TanStack Query Docs
"Parallel" queries are queries that are executed in parallel, or at the same time so as to maximize fetching concurrency. Manual Parallel Queries....
Read more >PostgreSQL Multiple Queries in one statement can be done ...
No, what you show is not run in parallel between the queries. You could submit the queries with dblink_send_query over different dblink ...
Read more >Documentation: 15: Chapter 15. Parallel Query - PostgreSQL
PostgreSQL can devise query plans that can leverage multiple CPUs in order to answer queries faster. This feature is known as parallel query....
Read more >Does two SQL server execute two queries in parallel? - MSDN
Scenario 1: two queries together in one editor, it takes about 2 minutes. Scenario 2: each query in a separate window, the running...
Read more >MS SQL Server: Do multiple queries in a batch ever execute in ...
Batch statements are only ever executed serially in the order they appear in the batch. Now, if you have two statements sent to...
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 Free
Top 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
Thank you for your replies you were very helpful!
Pool
doesn’t usepg.defaults
. Pass options:documentation