pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Lewis <mark.lewis@mir3.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Brian Choate <brianc@nimblefish.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Poor performance of delete by primary key
Date: Tue, 06 Sep 2005 10:04:38 -0700
Message-ID: <1126026278.3310.76.camel@archimedes> (raw)
In-Reply-To: <18162.1126020720@sss.pgh.pa.us>
References: <2F9239F5E316C54688FDA9814FF045D6EADACC@EXCHANGE.sf.nimblefish.com>
	<18162.1126020720@sss.pgh.pa.us>

I had a similar problem, so I downloaded 8.1 from CVS, ran it on a
relatively gnarly dev workstation, imported a dump of my 8.0 database,
and ran my troublesome queries with the new EXPLAIN ANALYZE.

This process took about an hour and worked great, provided that you've
actually named your foreign key constraints.  Otherwise, you'll find out
that there's a trigger for a constraint called $3 that's taking up all
of your time, but you won't know what table that constraint is on.

-- Mark



On Tue, 2005-09-06 at 11:32 -0400, Tom Lane wrote:
> "Brian Choate" <brianc@nimblefish.com> writes:
> > We are seeing a very strange behavior from postgres. For one of our very =
> > common tasks we have to delete records from a table of around 500,000 =
> > rows. The delete is by id which is the primary key. It seems to be =
> > consistently taking around 10 minutes to preform. This is totally out of =
> > line with the rest of the performance of the database.
> 
> I'll bet this table has foreign-key references from elsewhere, and the
> referencing columns are either not indexed, or not of the same datatype
> as the master column.
> 
> Unfortunately there's no very simple way to determine which FK is the
> problem.  (In 8.1 it'll be possible to do that with EXPLAIN ANALYZE,
> but in existing releases EXPLAIN doesn't break out the time spent in
> each trigger ...)  You have to just eyeball the schema :-(.
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faq




view thread (8+ messages)  latest in thread

Message-ID: <1126026278.3310.76.camel@archimedes>
Permalink:  ../1126026278.3310.76.camel@archimedes/
Also on:    postgresql.org/message-id/1126026278.3310.76.camel@archimedes

 · 

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: mark.lewis@mir3.com, tgl@sss.pgh.pa.us, brianc@nimblefish.com
  Subject: Re: Poor performance of delete by primary key
  In-Reply-To: <1126026278.3310.76.camel@archimedes>

* 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