Re: Foreign Key/ALTER TABLE Issue

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Rao Kumar <raokumar(at)netwolves(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Foreign Key/ALTER TABLE Issue
Date: 2002-06-25 21:19:05
Message-ID: 20020625141152.L80275-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 25 Jun 2002, Rao Kumar wrote:

> I have noticed that unlike indexes/check constrains, "ALTER TABLE ADD
> CONSTRAINT <c_name> FOREIGN KEY ..." statement does NOT prevent a user from
> re-creating an existing constraint more than once. Following this, a pg_dump
> on the table showed multiple entries of the foreign key constraint/trigger
> definitions.

Correct. The assumption is that the user knows what he or she is doing
(and thus that the constraints are different in some way). We might want
to change this at some point, but this isn't only foreign keys (you can
do the same with unique indexes or check constraints afaik) and should
probably be dealt with as such.

> My concerns are:
>
> If it ends up creating multiple triggers (doing the same task), do all these
> triggers get executed for each DML operation ?.

Yes.

> Will this cause a performance hit, if so is there a work-around to
> remove duplicate entries from the sys tables ?

You can remove one set of the triggers from pg_trigger which is pretty
much the only way right now to drop a foreign key constraint.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2002-06-25 21:31:52 Re: Postgres idea list
Previous Message Neil Conway 2002-06-25 21:19:04 Re: Democracy and organisation : let's make a