Postgresql Performance - Adjusting SHMMAX and SHMALL

Solution 1:

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

Solution 2:

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.