pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John R Pierce <pierce@hogranch.com>
To: pgsql-general@postgresql.org
Subject: Re: Out of memory
Date: Tue, 05 Apr 2011 12:27:27 -0700
Message-ID: <4D9B6D1F.9050406@hogranch.com> (raw)
In-Reply-To: <666FB8D75E95AE42965A0E76A5E5337E06DCC19F63@prdlsmmsg01.ad.linz.govt.nz>
References: <666FB8D75E95AE42965A0E76A5E5337E06DCC19F63@prdlsmmsg01.ad.linz.govt.nz>

On 04/05/11 2:50 AM, Jeremy Palmer wrote:
> I've been having repeated troubles trying to get a PostgreSQL app to play nicely on Ubuntu. I recently posted a message on this list about an out of memory error and got a resolution by reducing the work_mem setting. However I'm now getting further out of memory issues during the same stage of plpgsql function as mentioned before.
>
> The function itself is run as part of larger transaction which does the following:
>
> 1/ Maintains 104 tables (15 PostGIS tables), by loading and applying incremental table changes. A typical incremental load with maintain about 10,000 rows.
>
> 2/ When each one of these tables is updated an after trigger is fired that maintains an associated table revision table.
>
> 3/ After all of the tables are maintained a plpgsql function is called to build/maintain a set of de-normalised tables. These tables total about 20GB. Each one of these tables is compared against the previous table revision to determine its row changes. It's in this function that the out of memory exception is occurring.

a few random questions...

Does that all really have to be a single transaction?

Do you really need to use triggers for your revision tracking, and can't 
rely on your daily update cycle to manually set the revision information?

Is it really necessary to generate massive denormalized tables, rather 
than using view's to join the data?


> shared_buffers = 512MB
> maintenance_work_mem = 512MB
> temp_buffers = 256MB
> work_mem = 1MB
> wal_buffers = 16MB
> effective_cache_size = 4094MB
>
> The size of the database is 350GB. The typical number of users connected to the database is 1 or 2. This database is used for loading external data, managing revision table information and generating and outputting de-normalised datasets, so it does not have a high number of transactions running. Typically 1 large one per day.


with only 1-2 connections, you certainly could increase the work_mem. 
Alternately, this single giant transaction could manually set a larger 
work_mem which would only apply to it.   Personally, given your 8gb 
system and what you've described, I think I'd set the tuning parameters 
something like...

	shared_buffers = 1GB
	maintenance_work_mem = 128MB
	temp_buffers = 64MB
	work_mem = 16MB
	wal_buffers = 16MB
	effective_cache_size = 4094MB


adjust effective_cache_size to somewhat less than the 'cached' value 
shown in `free -m` after your system has been running for awhile.



view thread (58+ messages)  latest in thread

Message-ID: <4D9B6D1F.9050406@hogranch.com>
Permalink:  ../4D9B6D1F.9050406@hogranch.com/
Also on:    postgresql.org/message-id/4D9B6D1F.9050406@hogranch.com

 · 

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-general@postgresql.org
  Cc: pierce@hogranch.com
  Subject: Re: Out of memory
  In-Reply-To: <4D9B6D1F.9050406@hogranch.com>
  References: <666FB8D75E95AE42965A0E76A5E5337E06DCC19F63@prdlsmmsg01.ad.linz.govt.nz> <4D9B6D1F.9050406@hogranch.com>

* 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