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?

Enrico
  • 491
  • 2
  • 6
  • 15

2 Answers2

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

Mischa
  • 183
  • 8
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.

Khaled
  • 36,533
  • 8
  • 72
  • 99
  • 2
    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 http://manpages.ubuntu.com/manpages/jaunty/man2/shmget.2.html – Khaled Dec 18 '11 at 12:14