Re: SHMMAX and SHMALL question - Mailing list pgsql-general

From Greg Smith
Subject Re: SHMMAX and SHMALL question
Date
Msg-id 4D3B1F75.8040405@2ndquadrant.com
Whole thread Raw
In response to SHMMAX and SHMALL question  (DM <dm.aeqa@gmail.com>)
Responses Re: SHMMAX and SHMALL question  (D M <dm.aeqa@gmail.com>)
List pgsql-general
DM wrote:
> RAM = 16GB, what value should i set for shmall?

Given that PostgreSQL rarely sees increasing improvement as
shared_buffers goes over 50% of RAM, I just use that figure for the
shmall and then compute shmmax based on the page size to match it.  I
use the attached script to do all the hard work, haven't found a Linux
system yet it didn't do the right thing on.  It sounds like you might
have the math on the relation between the two backwards, look at the
output and code of this once and that should sort things out for you.

--
Greg Smith   2ndQuadrant US    greg@2ndQuadrant.com   Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support  www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

#!/bin/bash

# Output lines suitable for sysctl configuration based
# on total amount of RAM on the system.  The output
# will allow up to 50% of physical memory to be allocated
# into shared memory.

# On Linux, you can use it as follows (as root):
#
# ./shmsetup >> /etc/sysctl.conf
# sysctl -p

# Early FreeBSD versions do not support the sysconf interface
# used here.  The exact version where this works hasn't
# been confirmed yet.

page_size=`getconf PAGE_SIZE`
phys_pages=`getconf _PHYS_PAGES`

if [ -z "$page_size" ]; then
  echo Error:  cannot determine page size
  exit 1
fi

if [ -z "$phys_pages" ]; then
  echo Error:  cannot determine number of memory pages
  exit 2
fi

shmall=`expr $phys_pages / 2`
shmmax=`expr $shmall \* $page_size`

echo \# Maximum shared segment size in bytes
echo kernel.shmmax = $shmmax
echo \# Maximum number of shared memory segments in pages
echo kernel.shmall = $shmall

pgsql-general by date:

Previous
From: Christian Ullrich
Date:
Subject: Re: Using copy for WAL archiving on Windows
Next
From: "Andrus Moor"
Date:
Subject: Re: Server stops responding in every week