pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kenneth Marshall <ktm@rice.edu>
To: Mark Stosberg <mark@summersault.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: debugging handle exhaustion and 15 min/ 5mil row delete
Date: Fri, 7 May 2010 08:42:15 -0500
Message-ID: <20100507134215.GD18848@aart.is.rice.edu> (raw)
In-Reply-To: <20100507093742.20c715b1@summersault.com>
References: <20100507093742.20c715b1@summersault.com>

On Fri, May 07, 2010 at 09:37:42AM -0400, Mark Stosberg wrote:
> 
> Hello,
> 
> We've been a satified user of PostgreSQL for several years, and use it
> to power a national pet adoption website: http://www.adoptapet.com/
> 
> Recently we've had a regularly-timed middle-of-the-night problem where
> database handles are exhausted for a very brief period.
> 
> In tracking it down, I have found that the event seems to correspond to
> a time when a cron script is deleting from a large logging table, but
> I'm not certain if this is the cause or a correlation.
> 
> We are deleting about 5 million rows from a time-based logging table
> that is replicated by Slony. We are currently using a single delete
> statement, which takes about 15 minutes to run. There is no RI on the
> table, but the use of Slony means that a trigger call and action is made
> for every row deleted, which causes a corresponding insertion in another
> table so the deletion can be replicated to the slave.
> 
> My questions:
> 
> - Could this kind of activity lead to an upward spiral in database
>   handle usage?
Yes.
> 
> - Would it be advisable to use several small DELETE statements instead,
>   to delete rows in batches of 1,000. We could use the recipe for this
>   that was posted earlier to this list:
Yes, that is the method we use in several cases to avoid this behavior.
Deletion is a more intensive process in PostgreSQL, so batching it will
keep from dragging down other queries which results in your out-of-handles
error.

Regards,
Ken



view thread (5+ messages)  latest in thread

Message-ID: <20100507134215.GD18848@aart.is.rice.edu>
Permalink:  ../20100507134215.GD18848@aart.is.rice.edu/
Also on:    postgresql.org/message-id/20100507134215.GD18848@aart.is.rice.edu

 · 

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: ktm@rice.edu, mark@summersault.com
  Subject: Re: debugging handle exhaustion and 15 min/ 5mil row delete
  In-Reply-To: <20100507134215.GD18848@aart.is.rice.edu>

* 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