Re: Extremely slow DELETE with cascade foreign keys - Mailing list pgsql-performance

From Rodrigo Rosenfeld Rosas
Subject Re: Extremely slow DELETE with cascade foreign keys
Date
Msg-id 311dd1bb-1295-bf0d-eed7-55742a18484a@gmail.com
Whole thread Raw
In response to Re: Extremely slow DELETE with cascade foreign keys  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
Em 05-12-2017 14:27, Tom Lane escreveu:
> Rodrigo Rosenfeld Rosas <rr.rosas@gmail.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


Thanks, indeed that was the case. I manually inspected about a dozen 
tables referencing field_values and the last one ("references") was 
referenced by another table ("highlighted_texts") and the reference_id 
column that has a foreign key on "references"(id) was missing an index.

Good job :)

Best,

Rodrigo.



pgsql-performance by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Extremely slow DELETE with cascade foreign keys
Next
From: Rodrigo Rosenfeld Rosas
Date:
Subject: Re: Extremely slow DELETE with cascade foreign keys