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

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




view thread (10+ messages)  latest in thread

Message-ID: <7973.1512491234@sss.pgh.pa.us>
Permalink:  ../7973.1512491234@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7973.1512491234@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, rr.rosas@gmail.com, pgsql-performance@lists.postgresql.org
  Subject: Re: Extremely slow DELETE with cascade foreign keys
  In-Reply-To: <7973.1512491234@sss.pgh.pa.us>

* 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