pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: postgres@leangen.net
Cc: pgsql-performance@postgresql.org
Subject: Re: Delete operation VERY slow...
Date: Fri, 16 Jun 2006 09:30:32 -0400
Message-ID: <16186.1150464632@sss.pgh.pa.us> (raw)
In-Reply-To: <1150445542.4812.34.camel@sonoda.bioscene.co.jp>
References: <1150441126.4812.23.camel@sonoda.bioscene.co.jp>
	<674d1f8a0606160022p1b042676gba28553bac5ab5ea@mail.gmail.com>
	<1150445542.4812.34.camel@sonoda.bioscene.co.jp>

David Leangen <postgres@leangen.net> writes:
> The only inconvenience is that I need to remove all the foreign key
> constraints before truncating, then put them back after.

I was about to ask if you had any.  Usually the reason for DELETE being
slow is that you have foreign key references to (not from) the table and
the referencing columns aren't indexed.  This forces a seqscan search
of the referencing table for each row deleted :-(

			regards, tom lane



view thread (6+ messages)

Message-ID: <16186.1150464632@sss.pgh.pa.us>
Permalink:  ../16186.1150464632@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16186.1150464632@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, postgres@leangen.net
  Subject: Re: Delete operation VERY slow...
  In-Reply-To: <16186.1150464632@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