I usually start Postgres with pg_ctl -D /db start
How can I make it start under "nice", so it runs at a lower priority?
I usually start Postgres with pg_ctl -D /db start
How can I make it start under "nice", so it runs at a lower priority?
You have to "nice" all backend processes, not just the postmaster: http://wiki.postgresql.org/wiki/Priorities
Under systemd you may need something more like this - note that here (Debian/Ubuntu) the engine version and cluster name can being used to control a specific service, but this might not be the case for your distribution:
# systemctl edit postgresql@10-main
[Service]
Nice=15
IOSchedulingClass=2
IOSchedulingPriority=7
# service postgresql@10-main restart
I've included I/O scheduling as you may also wish to control this, but of course you can leave this out. It may be set automatically depending on the nice level if you do not set it explicitly. Lower is a higher priority, 0-7 within class 2 (best-effort). Class 3 is idle. Class 1 is realtime, you probably don't want it.
nice pg_ctl -D /db start
Use nice command to run a program with modified scheduling priority / nicenesses. Nicenesses range at least from -20 (resulting in the most favorable scheduling) through 19 (the least favorable). The default behavior is to increase the niceness by 10.
A niceness should not be confused with a scheduling priority, which lets applications determine the order in which threads are scheduled to run. Unlike a priority, a niceness is merely advice to the scheduler, which the scheduler is free to ignore.