pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Forest Wilkinson <fspam@home.com>
To: Jan Wieck <janwieck@Yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: unreferenced primary keys: garbage collection
Date: Tue, 23 Jan 2001 20:35:27 -0800
Message-ID: <d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com> (raw)
In-Reply-To: <200101222219.RAA15009@jupiter.jw.home>
References: <200101202213.RAA12172@jupiter.jw.home>
	<200101222219.RAA15009@jupiter.jw.home>

Jan,

Thanks for the reply, but your solution is rather unattractive to me.  It
requires that, any time a reference to an address id is changed, five
tables be searched for the address id.  This will create unwanted overhead
every time a change is made.  In order to make those searches even
remotely fast, I'd have to add indexes to every one of those tables, which
will mean an additional performance hit on table inserts.  Moreover, if a
new table is created that references address ids, and the maintainer at
the time forgets to rewrite those trigger functions, the system will
break.

I'd much rather be able to simply attempt a delete of any given address,
relying on referential integrity to prevent the delete if the address is
still being referenced.  I don't see why postgres has to treat such a
situation as a fatal error.  If postgres issued (for example) a warning
instead of an error here, I'd be home free!  Hasn't there been some talk
on the lists about this lately?

Forest

Jan Wieck wrote:
>>     While  this  behaviour  makes  sense  in  your case, it's not
>>     subject  to  referential  integrity  constraints.  You  could
>>     arrange  for  it with custom trigger procedures, checking all
>>     the five tables on DELETE or UPDATE on one of them.

Forest Wilkinson wrote:
>> > I have a database in which five separate tables may (or may not) reference
>> > any given row in a table of postal addresses.  I am using the primary /
>> > foreign key support in postgres 7 to represent these references.
>> >
>> > My problem is that, any time a reference is removed (either by deleting or
>> > updating a row in one of the five referencing tables), no garbage
>> > collection is being performed on the address table.  That is, when the
>> > last reference to an address record goes away, the record is not removed
>> > from the address table.  Over time, my database will fill up with
>> > abandoned address records.




view thread (7+ messages)  latest in thread

Message-ID: <d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com>
Permalink:  ../d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com/
Also on:    postgresql.org/message-id/d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: fspam@home.com, janwieck@Yahoo.com
  Subject: Re: unreferenced primary keys: garbage collection
  In-Reply-To: <d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com>
  References: <200101202213.RAA12172@jupiter.jw.home> <200101222219.RAA15009@jupiter.jw.home> <d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox