Skip site navigation (1) Skip section navigation (2)

Re: Poor performance of delete by primary key

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brian Choate" <brianc(at)nimblefish(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Poor performance of delete by primary key
Date: 2005-09-06 15:32:00
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
"Brian Choate" <brianc(at)nimblefish(dot)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

In response to


pgsql-performance by date

Next:From: Matthew SackmanDate: 2005-09-06 15:43:15
Subject: Re: Poor performance of delete by primary key
Previous:From: Marc CousinDate: 2005-09-06 15:13:41
Subject: Re: insert performance for win32

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group