pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Extremely slow DELETE with cascade foreign keys
Date: Tue, 5 Dec 2017 15:00:41 -0200
Message-ID: <311dd1bb-1295-bf0d-eed7-55742a18484a@gmail.com> (raw)
In-Reply-To: <7973.1512491234@sss.pgh.pa.us>
References: <8f569ed9-fde9-1fe7-4beb-01945009e040@gmail.com>
	<7973.1512491234@sss.pgh.pa.us>

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.





view thread (10+ messages)  latest in thread

Message-ID: <311dd1bb-1295-bf0d-eed7-55742a18484a@gmail.com>
Permalink:  ../311dd1bb-1295-bf0d-eed7-55742a18484a@gmail.com/
Also on:    postgresql.org/message-id/311dd1bb-1295-bf0d-eed7-55742a18484a@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: rr.rosas@gmail.com, tgl@sss.pgh.pa.us, pgsql-performance@lists.postgresql.org
  Subject: Re: Extremely slow DELETE with cascade foreign keys
  In-Reply-To: <311dd1bb-1295-bf0d-eed7-55742a18484a@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox