Re: Poor performance for delete query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jonatan Evald Buus <jonatan(dot)buus(at)cellpointmobile(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Poor performance for delete query
Date: 2014-04-24 21:25:03
Message-ID: 29874.1398374703@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jonatan Evald Buus <jonatan(dot)buus(at)cellpointmobile(dot)com> writes:
> On 24 April 2014 22:29, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I'd really have to bet that you forgot to index one of the referencing
>> tables.

> *That was our first thought, so we went through the child tables to check
> but apparently we missed some. (please see below for the difference in the
> explain analyze output)*

I'm confused. Your second EXPLAIN ANALYZE looks like you fixed the
problem. Are you still thinking there's an issue?

> Why is "order2transaction_fk" being triggered twice? Is that because
> there're two affected rows?

No, I'd have expected a delete of multiple rows to show as calls=N,
not N separate entries.

Maybe there are recursive queries buried under here somewhere?
That is, are you expecting any of the cascaded deletes to cascade further?
I don't recall exactly what EXPLAIN is likely to do with such cases.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jonatan Evald Buus 2014-04-25 05:04:59 Re: Poor performance for delete query
Previous Message Jonatan Evald Buus 2014-04-24 20:57:05 Re: Poor performance for delete query