X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id DA71D9FA5E2 for ; Wed, 20 Sep 2006 06:24:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 61702-01 for ; Wed, 20 Sep 2006 09:24:14 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id BF99C9FA0FB for ; Wed, 20 Sep 2006 06:24:13 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (84-72-188-217.dclient.hispeed.ch [84.72.188.217]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id CE22A656CB; Wed, 20 Sep 2006 11:26:31 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 10CE2184B7060; Wed, 20 Sep 2006 11:24:15 +0200 (CEST) Message-ID: <451108BE.5090905@logix-tt.com> Date: Wed, 20 Sep 2006 11:24:14 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Thunderbird 1.5.0.5 (X11/20060812) MIME-Version: 1.0 To: Henry Ortega Cc: pgsql-sql@postgresql.org Subject: Re: Make Trigger run after completion of ENTIRE transaction References: <2bffcc330609191200l5e84ec23x8db6b7beb89532e5@mail.gmail.com> In-Reply-To: <2bffcc330609191200l5e84ec23x8db6b7beb89532e5@mail.gmail.com> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200609/137 X-Sequence-Number: 26348 Hi, Henry, Henry Ortega wrote: > This maybe more of a theoretical question, can you actually make a > Trigger run > after completion of the entire transaction? [...] > ........... another 20-30 more inserts.......... Which frontend do yu use? Maybe COPY is better than insert. > The trigger actually runs on each Insert and therefore slows down the > Insert quite a bit. This sounds like the trigger itsself could be optimized a bit, or does some work that is not best suited to be in a trigger. > My question is, can you tell the trigger to run after Commit? I assume the trigger has to do some integrity checking work? Could you reformulate it as foreign key or check constraints? (you may even call a complex plpgsql function from the check constraint). Most constraint checks can be deferred to the end of the transaction, see the docs for more details. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org