X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0981853F8C for ; Thu, 14 Apr 2005 12:14:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03948-07 for ; Thu, 14 Apr 2005 15:13:59 +0000 (GMT) Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) by svr1.postgresql.org (Postfix) with ESMTP id D200353F90 for ; Thu, 14 Apr 2005 12:13:58 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with ESMTP id 6D3A111DE51; Thu, 14 Apr 2005 23:11:52 +0800 (WST) Received: from vscan02.westnet.com.au ([127.0.0.1]) by localhost (vscan02.westnet.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 21378-15; Thu, 14 Apr 2005 23:11:52 +0800 (WST) Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au [202.72.133.22]) by vscan02.westnet.com.au (Postfix) with ESMTP id E9BFA11DE3C; Thu, 14 Apr 2005 23:11:51 +0800 (WST) Message-ID: <425E88B7.6000203@familyhealth.com.au> Date: Thu, 14 Apr 2005 23:13:59 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard van den Berg Cc: pgsql-performance@postgresql.org Subject: Re: Foreign key slows down copy/insert 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> In-Reply-To: <425E8766.8070901@trust-factory.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/288 X-Sequence-Number: 11685 > 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