Re: Slow delete with with cascading foreign keys

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Matthias Karlsson" <matthias(at)yacc(dot)se>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Slow delete with with cascading foreign keys
Date: 2008-10-20 13:08:47
Message-ID: 27718.1224508127@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Matthias Karlsson" <matthias(at)yacc(dot)se> writes:
> I have a rather complex set of relations, connected with cascading
> foreign keys on delete. I'm experiencing very slow performance when
> deleting *the* lead node, which everything eventually depends on. The
> number of records ultimately to be deleted aren't that many (perhaps
> 2000-3000) but there are maybe 30 relations involved. I understand
> that this is most likely due to missing indices, but I have been
> unable to figure out how to get PostgreSQL to tell me where the
> performance bottleneck is.

If it's a reasonably modern PG version, EXPLAIN ANALYZE will break out
the time spent in each on-delete trigger, which should be enough to
answer the question.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Konoplev 2008-10-20 13:11:21 index scan leads to result that is different from sec scan after upgrading to 8.3.4
Previous Message Matthias Karlsson 2008-10-20 12:46:05 Slow delete with with cascading foreign keys