pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Chris <ctlajoie@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: How to troubleshoot high mem usage by postgres?
Date: Sat, 27 Feb 2010 17:39:33 -0500
Message-ID: <18568.1267310373@sss.pgh.pa.us> (raw)
In-Reply-To: <57033cf81002271429wb0da13am37b3cb6258103ea5@mail.gmail.com>
References: <57033cf81002271429wb0da13am37b3cb6258103ea5@mail.gmail.com>

Chris <ctlajoie@gmail.com> writes:
> Hi, I'm having an issue where a postgres process is taking too much
> memory when performing many consecutive inserts and updates from a PHP
> script (running on the command line). I would like to know what sort
> of logging I can turn on to help me determine what is causing memory
> to be consumed and not released.

Are you doing all these inserts/updates within a single transaction?

If so, I think the odds are very good that what's eating the memory
is the list of pending trigger actions, resulting from either
user-created triggers or foreign-key check triggers.  The best way
of limiting the problem is to commit more often.

If you want to try to confirm that, what I would do is run the
postmaster under a more restrictive ulimit setting, so that it
runs out of memory sometime before the system starts to swap.
When it does run out of memory, you'll get a memory context map
printed to postmaster stderr, and that will show which context
is eating all the memory.  If it's "AfterTriggerEvents" then my
guess above is correct --- otherwise post the map for inspection.

			regards, tom lane



view thread (7+ messages)  latest in thread

Message-ID: <18568.1267310373@sss.pgh.pa.us>
Permalink:  ../18568.1267310373@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18568.1267310373@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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ctlajoie@gmail.com
  Subject: Re: How to troubleshoot high mem usage by postgres?
  In-Reply-To: <18568.1267310373@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