Ubuntu – Postgresql Performance – Adjusting SHMMAX and SHMALL

debianpostgresqlshmmaxsysctlUbuntu

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?

Best Answer

For all Linux systems which I used SHMALL is measured in pages and SHMMAX is measured in bytes. I think you may check your system using ipcs command, which always converts above parameters in KBytes while output, and compare it with sysctl values:

[aseryozhin@centos ~]$ ipcs -l

------ Shared Memory Limits --------
max number of segments = 4096               // SHMMNI   
max seg size (kbytes) = 524288              // SHMMAX
max total shared memory (kbytes) = 8388608  // SHMALL
min seg size (bytes) = 1

[aseryozhin@centos ~]$ sysctl -e kernel.shmmax
kernel.shmmax = 536870912

[aseryozhin@centos ~]$ sysctl -e kernel.shmall
kernel.shmall = 2097152

[aseryozhin@centos ~]$ getconf PAGE_SIZE
4096

SHMMAX: 524288 * 1024 = 536870912

SHMALL: 8388608 * 1024 / 4096 = 2097152