I've read just about everything there is online about improving postgres performance, but the "right" values for SHMMAX and SHMALL still elude me.
The consensus seems to be SHMMAX = total_memory/4 and SHMALL = total_memory/2 are safe starting values.
However, SHMALL can be measured in pages or bytes and I can't find any info about which is used on Ubuntu.
Does Ubuntu (or more generally Debian) use pages or bytes for SHMALL?
For all Linux systems which I used
SHMALL
is measured in pages andSHMMAX
is measured in bytes. I think you may check your system usingipcs
command, which always converts above parameters in KBytes while output, and compare it withsysctl
values:SHMMAX: 524288 * 1024 = 536870912
SHMALL: 8388608 * 1024 / 4096 = 2097152
These variables are measured in bytes as stated in the documentation. I think it is more important to look at the postgresql configuration parameters. You need to look at the SHMALL/SHMMAX values when needed. For example, if you want to increase the maximum number of connections, you may need to increase these limits.
Tuning the database server depends on your usage pattern such as the number of simultaneous connections and the database size. Increasing a config parameter is not always good.