Re: on update / on delete performance of foreign keys - Mailing list pgsql-general

From Richard Huxton
Subject Re: on update / on delete performance of foreign keys
Date
Msg-id 41F4FD14.1040401@archonet.com
Whole thread Raw
In response to on update / on delete performance of foreign keys  ("Florian G. Pflug" <fgp@phlo.org>)
Responses Re: on update / on delete performance of foreign keys
List pgsql-general
Florian G. Pflug wrote:
> Hi
>
> I ran into some performance problems regarding foreign keys lately.
> My schema has about 20 tables, which each contain from 10 to 100.000
> records. They have quite complicated interdependencies, modeled using
> foregin keys set to "on update cascade, on delete cascade".
> The schema stores data for multiple customers - Recently I wanted
> to extract the data for just a single customer. I duplicated the schema,
> and deleted all but one customer from the "customer" table. This worked
> as expected, but the delete took a few hours (!) on a moderatly fast
> machine (dual 1GHz PIII, RAID5-Array for postgres-data).

PostgreSQL doesn't automatically add indexes to foreign-key columns.
That sounds like the issue to me.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: "Florian G. Pflug"
Date:
Subject: on update / on delete performance of foreign keys
Next
From: Greg Stark
Date:
Subject: Re: How are foreign key constraints built?