Re: Update and foreign key indices

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Nikhil G(dot) Daddikar" <ngd(at)celoxis(dot)com>
Cc: pggeneral <pgsql-general(at)postgresql(dot)org>
Subject: Re: Update and foreign key indices
Date: 2002-08-05 14:31:51
Message-ID: 20020805072825.N71706-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 5 Aug 2002, Nikhil G. Daddikar wrote:

> Hello Folks,
>
> I will ask my question through an example:
>
>
> 1) I have table PROJECT that has a foreign key USER_ID references
> USER(ID)
>
> 2) I *don't* use USER_ID in a where clause so don't have to create
> indices for performance reason.
>
> 3) USER table's primary key *never* changes.
>
> Q: Do I have to create an index for FK USER_ID to speed up updates to
> USER table rows?
>
>
> Basically, is PG nice enough to understand that since a key is not
> updated, it need not check the integrity constraints.

It should not run the select if the old value of the key equals the
new one (for each row). I don't have 7.1 to check, but running the
query would cause obvious broken behavior so I figure it probably
hasn't since inception.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lamar Owen 2002-08-05 14:58:53 Re: Installing postgresql
Previous Message Tom Lane 2002-08-05 14:28:41 Re: Puzzling planner choice (non-urgent)