Checking FKs after COPY and disabled Triggers - Mailing list pgsql-general

From Janning Vygen
Subject Checking FKs after COPY and disabled Triggers
Date
Msg-id 200404011021.41547.vygen@gmx.de
Whole thread Raw
Responses Re: Checking FKs after COPY and disabled Triggers
List pgsql-general
hi PGurus,

i searched the archives and read the docs, because this problem shouldn't be
new. But i really don't know what to search for.

i am populating a database (v7.4.1) with COPY. Some triggers in the db schema
fire on inserts and do some additional data manipulations, which i dont want
to take place by running COPY because my data don't need those additional
manipulation. Therefor and for performance reasons, i disable all triggers
with commands like this (stolen from pg_dump output)

UPDATE pg_catalog.pg_class SET reltriggers = 0 WHERE oid =
'Customers'::pg_catalog.regclass;

of course i enable them afterwards. This does in fact diable Foreign Key
Constraints too, right? And that's nice because i think its much faster.

My problem: my COPY data files are build by perl scripts which might be buggy.
i would like to check that all FKs are correct after or while populating the
data.

1. Can i disable my triggers without disabling FK constraints? if yes, how?

2. If no to question 1 or lacks performance:
can i check my database for violating FKs if i populated the database with FK
constraints disabled? I guess there is a SQL query which consults some
pg_catalog tables and checks all fk integrity

Any help is very appreciated.

kind regards,
janning


pgsql-general by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: [pgsql-advocacy] Best open source db poll currently
Next
From: Richard Huxton
Date:
Subject: Re: select distinct w/order by