Re: Extremely slow DELETE with cascade foreign keys

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rodrigo Rosenfeld Rosas <rr(dot)rosas(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Extremely slow DELETE with cascade foreign keys
Date: 2017-12-05 16:27:14
Message-ID: 7973.1512491234@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Rodrigo Rosenfeld Rosas <rr(dot)rosas(at)gmail(dot)com> writes:
> Hi, I think something changed recently in my development environment as
> I don't recall deletes being so slow before.
> I've created a new dump and restored to a new database, ran VACUUM FULL
> ANALYSE and a simple delete takes forever as you can see here:

The usual suspect for this is not having an index on some FK referencing
column, thus forcing the FK check trigger to seq-scan the entire
referencing table for each referenced row that is to be deleted.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Alvaro Herrera 2017-12-05 16:43:28 Re: Extremely slow DELETE with cascade foreign keys
Previous Message Rodrigo Rosenfeld Rosas 2017-12-05 16:21:38 Extremely slow DELETE with cascade foreign keys