SimonSays
SimonSays

Reputation: 75

Postgres Tuning max_worker_processes

I'm looking at turning for a very small postgres database (2 cores ver - 12.7) . Everything I have read so far says that the max_worker_processes should just be set to the number of cores allocated to postgres.

My question is, is there any harm to setting this above the number of cores?

Ultimately we're trying to use pg_cron with backend processes and for whatever reason pg_cron fails to launch a backend process if the max_worker_processes is set to less than 3.

We're considering updating max_worker_processes but we can't find any documentation or information that helps us know this won't cause other problems.

Upvotes: 5

Views: 11396

Answers (2)

Bradley H
Bradley H

Reputation: 11

When creating pg_cron jobs, make sure that the number of max_worker_processes is always greater than the number of cron.max_running_jobs. A pg_cron job will fail if it runs out of background worker processes. The default number of pg_cron jobs is 5;

Upvotes: 1

Laurenz Albe
Laurenz Albe

Reputation: 246643

max_worker_processes is the cluster-wide limit for the number of custom background workers and parallel workers.

Since pg_cron uses background workers, it will fail if you set the limit too low.

If you want to allow pg_cron to start enough workers, but you don't want to have too many parallel worker processes (to save on CPU resources), increase max_worker_processes but keep max_parallel_workers low.

The ideal settings will depend on your requirements and your workload.

Upvotes: 7

Related Questions