Re: when is a DELETE FK trigger planned? - Mailing list pgsql-performance

From Andrew Lazarus
Subject Re: when is a DELETE FK trigger planned?
Date
Msg-id 1069587644.20080227165420@pillette.com
Whole thread Raw
In response to Re: when is a DELETE FK trigger planned?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
I figured out what appears to happen with cascading delete using a
seqscan. In this case, the foreign keys in the child table are not
equally distributed. A few parent values occur often. Most parent
values do not occur at all. So the planner, faced with an unknown
generic key, takes the safe route.

What I've done is remove the FK (maybe it would be better to leave it
albeit disabled for documentation) and written my own AFTER DELETE
trigger that uses EXECUTE to delay planning until the actual value is
known. This appears to work correctly.

--
Sincerely,
 Andrew Lazarus        mailto:andrew@pillette.com
Attachment

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: disabling an index without deleting it?
Next
From: Joel Stevenson
Date:
Subject: Re: LISTEN / NOTIFY performance in 8.3