From: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: Richard van den Berg <richard.vandenberg@trust-factory.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Foreign key slows down copy/insert
Date: Thu, 14 Apr 2005 23:13:59 +0800
Message-ID: <425E88B7.6000203@familyhealth.com.au> (raw)
In-Reply-To: <425E8766.8070901@trust-factory.com>
References: <425E6045.4060201@trust-factory.com>
<425E792B.4020500@familyhealth.com.au>
<425E7D96.6020201@trust-factory.com>
<425E7F94.4080602@familyhealth.com.au>
<425E8766.8070901@trust-factory.com>
> Thanks for the pointer. I got this from the archives:
>
> ------------------------
> update pg_class set reltriggers=0 where relname = 'YOUR_TABLE_NAME';
>
> to enable them after you are done, do
>
> update pg_class set reltriggers = count(*) from pg_trigger where
> pg_class.oid=tgrelid and relname='YOUR_TABLE_NAME';
> ------------------------
>
> I assume the re-enabling will cause an error when the copy/insert added
> data that does not satisfy the FK. In that case I'll indeed end up with
> invalid data, but at least I will know about it.
No it certainly won't warn you. You have _avoided_ the check entirely.
That's why I was warning you...
If you wanted to be really careful, you could:
being;
lock tables for writes...
turn off triggers
insert
delete where rows don't match fk constraint
turn on triggers
commit;
Chris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: chriskl@familyhealth.com.au, richard.vandenberg@trust-factory.com
Subject: Re: Foreign key slows down copy/insert
In-Reply-To: <425E88B7.6000203@familyhealth.com.au>
References: <425E6045.4060201@trust-factory.com> <425E792B.4020500@familyhealth.com.au> <425E7D96.6020201@trust-factory.com> <425E7F94.4080602@familyhealth.com.au> <425E8766.8070901@trust-factory.com> <425E88B7.6000203@familyhealth.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox