Re: Deleting vs foreign keys

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: WireSpot <wirespot(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Deleting vs foreign keys
Date: 2005-10-24 23:39:18
Message-ID: 20051024233918.GA26633@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 25, 2005 at 12:59:27AM +0300, WireSpot wrote:
> I have an application that makes heavy use of foreign keys all over
> the tables. This is very nice since the data is very consistent. There
> also this "central" table which holds "sites" in it. A site pretty
> much is the crux of it all. Deleting a site will very precisely
> eliminate all data regarding it, since there's CASCADE on delete's
> everywhere.
>
> The only trouble I'm having is that the original developers apparently
> didn't account for large amounts of data. I'm starting to get a LOT of
> data in some tables, and nowadays deleting a site will take a
> disgusting amount of time (in the range of tens of minutes).

Are there indexes on the foreign key columns? That is, given
the following example,

CREATE TABLE foo (id integer PRIMARY KEY);
CREATE TABLE bar (fooid integer NOT NULL REFERENCES foo ON DELETE CASCADE);

do you have an index on bar.fooid? Also, do you regularly vacuum
and analyze the database?

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message krishnaa sridharan 2005-10-25 00:17:21 pl/pgsql help
Previous Message Michael Fuhr 2005-10-24 23:29:31 Re: Generic Q about max(id) vs ORDER BY ID DESC LIMIT 1