Re: SHMMAX and SHMALL question

From: D M <dm(dot)aeqa(at)gmail(dot)com>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: SHMMAX and SHMALL question
Date: 2011-01-23 00:09:46
Message-ID: 86E07050-550D-4A22-AE4A-D7C1E7D74761@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you so much for the script.

~deepak

On Jan 22, 2011, at 10:18 AM, Greg Smith <greg(at)2ndquadrant(dot)com> wrote:

> 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(at)2ndQuadrant(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2011-01-23 01:05:07 Re: Subquery for column names of tablefunc crosstab queries
Previous Message Scott Marlowe 2011-01-22 21:08:41 Re: Server stops responding in every week