1

We are a MySQL shop basically and we are familiar with MySQL's thread concurrency level, it uses an internal queue so that even when more number of connections/queries come in,the I/O is throttled and controlled.

The same cannot apply for Postgres since it is multi-process application.Now the questions,

If there are more number of connections,say 2000 connections come in, will all the queries be run parallel i.e 2000 processes will be spawned and be executed simultaneously ? If yes then what are its implications when a rogue query comes in and blocks the other queries, how is it handled internally?

Does postgres have some internal tunable parameter which is similar to MySQL ?

I would appreciate if people point me in the right direction.

1 Answer 1

1

The PostgreSQL architecture is based on UNIX processes - one session over database (one connect to database) means one process. If you have 1000 active conects, then there are 1000 PostgreSQL processes. The PostgreSQL by self doesn't support pooling or some similar. But you can use third party software. There are more variants - light pgbouncer, more complex and more heavy pgpoolII. This software is necessary, when you plan to have ten times higher number of connections than CPU cores. It helps too if you have dedicated server with lot of very short queries.

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

4 Comments

Thanks for the answer.Now I understand that there is no concurrency parameter that can be set, is it safe to assume that postgres will use up all the cores by default and will automatically queue all the requests ?
Postgres doesn't calculate the number of cores. It doesn't use any queue. It uses the processes - and the controlling of processes is a task for operation system.
So if all the cores are currently being used and there are more queries that keep coming in, as per my understanding now there is 1 query/core,do the pending queries get queued somewhere even by the OS or do they fail.I am aware of the max connections, but I am more concerned about the query count here.Hope I am not confusing you.
No :) The operation system can run more processes than there are CPU cores. The CPU time is shared between all processes. There is not any queue. All PostgreSQL processes are executed parallel with same priority.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.