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

From Greg Stark
Subject Re: on update / on delete performance of foreign keys
Date
Msg-id 87wtu26gt1.fsf@stark.xeocode.com
Whole thread Raw
In response to on update / on delete performance of foreign keys  ("Florian G. Pflug" <fgp@phlo.org>)
List pgsql-general
"Florian G. Pflug" <fgp@phlo.org> writes:

> when deleting a lot of rows from a large table - and each time it has to find
> referencing tuples by doing an index scan

Are you sure it was even an index scan? And not doing a sequential table scan
for every deletion? In order to do an index scan you need an index on foreign
key columns in the referencing tables, not just the referenced tables. Usually
people only think about the referenced tables because usually that's all they
need. Only when you start cascading updates and deletes do you need indexes on
the columns in the referencing tables.

--
greg

pgsql-general by date:

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