pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas O'Connell <tfo@monsterlabs.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: performance tuning: shared_buffers, sort_mem; swap
Date: Tue, 13 Aug 2002 17:26:56 -0400
Message-ID: <1372.1029274016@sss.pgh.pa.us> (raw)
In-Reply-To: <tfo-345314.14322213082002@news.hub.org>
References: <27214.1029257785@sss.pgh.pa.us>
	<tfo-549650.13201613082002@news.hub.org>
	<tfo-345314.14322213082002@news.hub.org>

"Thomas O'Connell" <tfo@monsterlabs.com> writes:
> for instance, if i set shared_buffers to 4096, this should mean 
> postmaster will require 4096 * 8192 = 33554432 bytes, right? but when i 
> start it, i get the error above with a request size of 38371328. what's 
> the extra padding from? sort_mem, etc?

No, sort_mem is backend-local.

postgresql.conf lists these parameters as affecting shared memory size:

#
#	Shared Memory Size
#
#shared_buffers = 64		# 2*max_connections, min 16
#max_fsm_relations = 100	# min 10, fsm is free space map
#max_fsm_pages = 10000		# min 1000, fsm is free space map
#max_locks_per_transaction = 64	# min 10
#wal_buffers = 8		# min 4

This list misses max_connections which also has nontrivial influence.

The multiplier for shared_buffers is somewhat higher than 8192, because
there's a buffer management block (bufhdr) to allocate as well as the
physical data block.  The lock table is sized on the basis of
max_locks_per_transaction * max_connections entries, and there are other
shared data structures that are per-backend so are sized as multiples of
max_connections.  I think the multiplier for max_fsm_pages is 6 bytes;
not sure about max_fsm_relations but it's probably a couple dozen bytes
per relation.

There are also a number of fixed-size data structures in shared memory,
and I believe we throw on a 10% fudge factor for good luck after we're
done counting up what we think we need.

You could work out the effective multipliers for these parameters with a
little bit of experimental effort...

			regards, tom lane



view thread (23+ messages)  latest in thread

Message-ID: <1372.1029274016@sss.pgh.pa.us>
Permalink:  ../1372.1029274016@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1372.1029274016@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tfo@monsterlabs.com
  Subject: Re: performance tuning: shared_buffers, sort_mem; swap
  In-Reply-To: <1372.1029274016@sss.pgh.pa.us>
  References: <27214.1029257785@sss.pgh.pa.us> <tfo-549650.13201613082002@news.hub.org> <tfo-345314.14322213082002@news.hub.org> <1372.1029274016@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox