Received: from femail2.sdc1.sfba.home.com (femail2.sdc1.sfba.home.com [24.0.95.82]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0K4rA086090 for ; Fri, 19 Jan 2001 23:53:10 -0500 (EST) (envelope-from fspam@home.com) Received: from tajar ([24.1.6.224]) by femail2.sdc1.sfba.home.com (InterMail vM.4.01.03.00 201-229-121) with SMTP id <20010120045243.PLUG10244.femail2.sdc1.sfba.home.com@tajar> for ; Fri, 19 Jan 2001 20:52:43 -0800 From: Forest Wilkinson To: pgsql-sql@postgresql.org Subject: unreferenced primary keys: garbage collection Date: Fri, 19 Jan 2001 20:54:21 -0800 Message-ID: <4l5i6tcr56fkb8hob8a3bas3ce0qq53d6l@4ax.com> 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/269 X-Sequence-Number: 938 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. I suppose I could write procedural code in my client application, to check for abandonment when a reference is removed, but that would require examining each of the five referencing tables. I consider this a messy option, and I expect it would be rather inefficient. I thought of attempting to delete the address record any time a reference to it is removed, and relying on foreign key constraints to prevent the deletion if it is referenced elsewhere. However, I believe postgres will force the entire transaction block to be rolled back in such cases, thus nullifying all the other work done in the transaction. This is clearly undesirable. Isn't there some way to tell postgres *not* to roll back my transaction if a particular DELETE fails due to referential integrity? Are there any other options that might help me? Regards, Forest Wilkinson