Re: Simple delete query is taking too long (never ends)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Massalin Yerzhan <yerzhik(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Simple delete query is taking too long (never ends)
Date: 2015-11-11 19:33:35
Message-ID: 17089.1447270415@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Massalin Yerzhan <yerzhik(at)gmail(dot)com> writes:
> I'm having an issue. The query never ends:
> delete from bb_gamelist_league;

9 times out of 10, the answer to this type of problem is that you have
some table referencing this one by a foreign key, and the referencing
column is not indexed. PG doesn't require such an index, but lack of
one will mean that retail checks or deletions of referencing rows are
really slow.

If you're not sure which table is the problem, try doing an EXPLAIN
ANALYZE of a DELETE that will only remove a few rows. You should
see some time blamed on a trigger associated with the FK constraint.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2015-11-12 15:12:51 Re: Simple delete query is taking too long (never ends)
Previous Message Massalin Yerzhan 2015-11-11 19:09:36 Simple delete query is taking too long (never ends)