Question

In SQL Server we can have many worker threads per CPU core. Does anyone know if the same is true in PostgreSQL and can point me at a reference? (assume version 11).

The background is that we have some OLTP workloads currently in SQL Server that are being migrated to PostgreSQL. I'm wondering if there is a risk of running out of threads if parallelism is enabled and connections being refused (which can happen on SQL Server when we run out of threads), and whether I should recommend that parallelism is disabled by default.

Was it helpful?

Solution

PostgreSQL does not use threads, it uses coordinated single-thread processes. It will not use more than max_parallel_workers, system-wide, at one time. If it would exceed that, the queries will not error out, they simply run with fewer worker processes than they "wanted".

If the number of connections you have trying to run queries at the same time is always greater than your number of CPUs, then you probably might as well turn parallelism off. OLTP usually are not great candidates for parallel execution anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top