Re: unreferenced primary keys: garbage collection

From: "Albert REINER" <areiner(at)tph(dot)tuwien(dot)ac(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: unreferenced primary keys: garbage collection
Date: 2001-01-24 19:36:39
Message-ID: 20010124203639.A203@frithjof
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> On Tue, 23 Jan 2001, Forest Wilkinson wrote:
>
> > 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

If - and I think this is the case for you - it is no problem for you
to have some superfluous adresses in your tables, but you only want to
avoid that those adresses remain there for a long time, you could
simply run the function Jan sent from a cron job. That seems to be
likely to be more efficient not only than the triggers but also to the
ON DELETE RESTRICT solution, I guess.

Trivial, but I HTH -

Albert.

> > 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.

--

--------------------------------------------------------------------------
Albert Reiner <areiner(at)tph(dot)tuwien(dot)ac(dot)at>
Deutsch * English * Esperanto * Latine
--------------------------------------------------------------------------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Glen and Rosanne Eustace 2001-01-24 19:49:27 Problem with Dates
Previous Message David Olbersen 2001-01-24 19:31:57 Please don't kill me!