Re: Delete operation VERY slow... - Mailing list pgsql-performance

From Tom Lane
Subject Re: Delete operation VERY slow...
Date
Msg-id 16186.1150464632@sss.pgh.pa.us
Whole thread Raw
In response to Re: Delete operation VERY slow...  (David Leangen <postgres@leangen.net>)
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Greg Stark
Date:
Subject: Re: Optimizer internals
Next
From: "Jonah H. Harris"
Date:
Subject: Re: Optimizer internals