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 20:29:00 |
Message-ID: | 28604.1398371340@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:
> We're currently having very poor performance for the following delete query.
> DELETE FROM TopTable WHERE id IN (xx, yy, zz);
> We've observed that it takes around 7 seconds under normal load to for each
> row that's being from TopTable and several minutes pr deleted row under
> heavy load.
I'd really have to bet that you forgot to index one of the referencing
tables. Are any of the foreign keys multi-column? If so you probably
need a matching multi-column index, not just indexes on the individual
referencing columns.
> How do we track down the cause of the poorly performing delete query?
EXPLAIN ANALYZE on a DELETE, for starters. That would isolate whether
it's the DELETE itself or one of the foreign-key updates, and if the
latter which one. It's a little bit difficult to see the exact plan being
used for a foreign-key update query, but I think one way you could do it
is to enable auto_explain with auto_explain.log_nested_statements turned
on.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jonatan Evald Buus | 2014-04-24 20:57:05 | Re: Poor performance for delete query |
Previous Message | Sergey Konoplev | 2014-04-24 19:57:50 | Re: tsearch2, large data and indexes |