Received: from femail11.sdc1.sfba.home.com (femail11.sdc1.sfba.home.com [24.0.95.107]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0O4Y4036186 for ; Tue, 23 Jan 2001 23:34:04 -0500 (EST) (envelope-from fspam@home.com) Received: from tajar ([24.1.6.224]) by femail11.sdc1.sfba.home.com (InterMail vM.4.01.03.00 201-229-121) with SMTP id <20010124043359.KUAV11834.femail11.sdc1.sfba.home.com@tajar>; Tue, 23 Jan 2001 20:33:59 -0800 From: Forest Wilkinson To: Jan Wieck Cc: pgsql-sql@postgresql.org Subject: Re: unreferenced primary keys: garbage collection Date: Tue, 23 Jan 2001 20:35:27 -0800 Message-ID: References: <200101202213.RAA12172@jupiter.jw.home> <200101222219.RAA15009@jupiter.jw.home> In-Reply-To: <200101222219.RAA15009@jupiter.jw.home> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200101/307 X-Sequence-Number: 976 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.