6

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.

2 Answers 2

8

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.

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

3 Comments

this followup may warrant a separate post but it's still related. Would you know the recommendation is to set max_worker_processes equal to the number of cores allocated to Postgres? I imagine there has to be some sort of reasoning behind it or the recommendation wouldn't exist. So far I haven't been able to find anything that might explain this.
I have never seen that recommendation anywhere. I wouldn't recommend that.
I agree, I saw this also in plenty of articles (not official) but I think they are confusing this with max_parallel_workers which @LaurenzAlbe mentioned
1

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;

Comments

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.