9

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?

2 Answers 2

11

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

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.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .