Re: when is a DELETE FK trigger planned?
От
Andrew Lazarus
Тема
Re: when is a DELETE FK trigger planned?
Дата
Msg-id
1069587644.20080227165420@pillette.com
Ответ на
Re: when is a DELETE FK trigger planned? (Tom Lane)
Список
Дерево обсуждения
when is a DELETE FK trigger planned? Andrew Lazarus <andrew@pillette.com>
Re: when is a DELETE FK trigger planned? Tom Lane <tgl@sss.pgh.pa.us>
Re: when is a DELETE FK trigger planned? Andrew Lazarus <andrew@pillette.com>
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
В списке pgsql-performance по дате отправления