pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bryce Nesbitt <bryce1@obviously.com>
To: pgsql-sql@postgresql.org
Subject: Re: Very slow DELETE on 4000 rows of 55000 row table
Date: Wed, 04 Apr 2007 21:17:19 -0700
Message-ID: <4614784F.3040901@obviously.com> (raw)
In-Reply-To: <21308.1175583840@sss.pgh.pa.us>
References: <4611EFE1.5010400@obviously.com>
	<21308.1175583840@sss.pgh.pa.us>

Tom Lane wrote:
> Bryce Nesbitt <bryce1@obviously.com> writes:
>   
>> I've got a DELETE FROM that seems to run forever, pegging the CPU at
>> 100%.  I can't figure out why it's slow.  Any clues?
>>     
>
> Unindexed foreign key constraints pointing to this table, perhaps?
> EXPLAIN ANALYZE would give a great deal more clue than plain EXPLAIN.
>
> 			regards, tom lane
>   
Hmm, excellent point.  There is a column with no index that points to
the table in question:

Indexes:
    "eg_order_line_pkey" PRIMARY KEY, btree (order_line_id)
    "ixf8331222783867cc" btree (order_id)
Foreign-key constraints:
    "fkf8331222783867cc" FOREIGN KEY (order_id) REFERENCES
eg_order(order_id)
    "fkf83312228edf278d" FOREIGN KEY (invoice_id) REFERENCES
eg_invoice(invoice_id)
    "order_line_to_cso" FOREIGN KEY (cso_id) REFERENCES eg_cso(cso_id)

But I DELETE all conflicting those rows prior to the slow DELETE, just
so the FK check is never hit.  Should I be looking at subverting the FK
check mechanism somehow?  The necessary index would be huge, and
relevant only on this particular operation which happens every few
months, if that.




view thread (5+ messages)  latest in thread

Message-ID: <4614784F.3040901@obviously.com>
Permalink:  ../4614784F.3040901@obviously.com/
Also on:    postgresql.org/message-id/4614784F.3040901@obviously.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bryce1@obviously.com
  Subject: Re: Very slow DELETE on 4000 rows of 55000 row table
  In-Reply-To: <4614784F.3040901@obviously.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