Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 10 down vote accepted

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

SHMMAX: 524288 * 1024 = 536870912

SHMALL: 8388608 * 1024 / 4096 = 2097152

share|improve this answer

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.

share|improve this answer
SHMMAX need to be increased in order to increase shared_buffers which is the lowest hanging fruit when it comes to postgresql performance. Can you add a link to the documentation? – Enrico Dec 16 '11 at 18:09
You can look at – Khaled Dec 18 '11 at 12:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.