From: | PFC <lists(at)peufeu(dot)com> |
---|---|
To: | postgres(at)leangen(dot)net, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Delete operation VERY slow... |
Date: | 2006-06-16 11:23:15 |
Message-ID: | op.ta8kk1aqcigqcu@apollo13 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
> Wow! That was almost instantaneous. I can't believe the difference.
>
> The only inconvenience is that I need to remove all the foreign key
> constraints before truncating, then put them back after. But I suppose
> it is a small price to pay for this incredible optimization.
In that case, your DELETE might have been slowed down by foreign key
checks.
Suppose you have tables A and B, and table A has a column "b_id
REFERENCES B(id)"
When you delete from B postgres has to lookup in A which rows reference
the deleted rows in order to do the ON DELETE action you specified in the
constraint.
If you do not have an index on b_id, this can be quite slow... so you
should check if your foreign key relations that need indexes have them.
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2006-06-16 11:23:26 | Re: Optimizer internals |
Previous Message | Michael Stone | 2006-06-16 11:23:04 | Re: how to partition disks |