Re: Problem Deleting Referenced records - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Problem Deleting Referenced records
Date
Msg-id 20031111190246.GB11772@wolff.to
Whole thread Raw
In response to Re: Problem Deleting Referenced records  (Alex <alex@meerkatsoft.com>)
List pgsql-general
On Wed, Nov 12, 2003 at 00:08:02 +0900,
  Alex <alex@meerkatsoft.com> wrote:
> Bruno,
> I am not sure why but the whole delete proces with the where not exists
> method took 3hrs, rather long I would say.
>
> Table A had 2.5mil records
> Table B had about 30k records
>
> In addition  Table C with about 2 mil records referenced a  referenced A
> (same key as B)
> In both A and B about 150k records where deleted... but the process took
> more than 3 hrs.
>
> Its pretty long I would say. I noticed in the past that if I had
> multiple foreign keys, referencing different tables like TableA <--
> TableB <-- TableC then deletes are really slow... sometimes in the area
> of one delete per second. Never really figured out why. (And yes I did
> run a Vacuum or Vacuum analyze on the DB
> or Tables).

If you do a lot of deleting of rows in referenced tables, then you probably
want to create indexes in the referencing tables for the key. This will
allow for quicker checks by the referential integrity checking triggers.

pgsql-general by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: [ANNOUNCE] PostgreSQL v7.4 Release Candidate 2
Next
From: "mboscia"
Date:
Subject: change conndeferrable in pg_constraint?