Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: when is a DELETE FK trigger planned?


  • From: Andrew Lazarus <andrew(at)pillette(dot)com>
  • To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • Cc: pgsql-performance(at)postgresql(dot)org
  • Subject: Re: when is a DELETE FK trigger planned?
  • Date: Wed, 27 Feb 2008 16:54:20 -0800
  • Message-id: <1069587644.20080227165420@pillette.com> <text/plain>

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(at)pillette(dot)com

Attachment: vCard.VCF
Description: Vcard



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group