Re: Delete operation VERY slow...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: postgres(at)leangen(dot)net
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Delete operation VERY slow...
Date: 2006-06-16 13:30:32
Message-ID: 16186.1150464632@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

David Leangen <postgres(at)leangen(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jonah H. Harris 2006-06-16 13:43:55 Re: Optimizer internals
Previous Message Greg Stark 2006-06-16 13:21:01 Re: Optimizer internals