Re: Adding foreign key constraints without integrity

From: Wes <wespvp(at)syntegra(dot)com>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Adding foreign key constraints without integrity
Date: 2006-06-19 12:44:23
Message-ID: C0BC0657.C713%wespvp@syntegra.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> You could create the fk-constraints _first_, then disable them, load
> the data, reindex, and reenable them afterwards.
>
> pg_dump/pg_restore can enable and disable fk-constraints before restoring
> the data, I believe. It does so by tweaking the system catalogs.

Are referring to '--disable-triggers' on pg_dump? Will this work for
foreign key constraints? The doc talks about triggers, but doesn't say
anything about FK constraints (are these implemented as triggers?) I don't
use pg_restore, just psql.

> The only problem I can see is that creating the fk-constraints might create
> some indices too. But maybe you can manually drop those indices afterwards - I
> don't know if the fk really _depends_ on the index, or if it creates it only
> for convenience.

I don't see any indexes being added to the table beyond what I add, and
those added as a primary key constraint. Currently, pg_dump outputs the FK
constraints after the indexes are built, as the last steps. If I try to add
the FK constraints after loading the database definitions, but without any
indexes, I'm not sure what would happen.

Wes

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Relyea, Mike 2006-06-19 12:46:53 Re: Out of memory error in 8.1.0 Win32
Previous Message Mustafa Korkmaz 2006-06-19 12:26:54 SELECT statement takes 10 minutes to answer