Re: on update / on delete performance of foreign keys

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: on update / on delete performance of foreign keys
Date: 2005-01-24 14:30:02
Message-ID: 87wtu26gt1.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"Florian G. Pflug" <fgp(at)phlo(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Florian G. Pflug 2005-01-24 14:39:09 Re: on update / on delete performance of foreign keys
Previous Message Greg Stark 2005-01-24 14:24:49 Re: How are foreign key constraints built?