Re: Make Trigger run after completion of ENTIRE transaction - Mailing list pgsql-sql

From Markus Schaber
Subject Re: Make Trigger run after completion of ENTIRE transaction
Date
Msg-id 451108BE.5090905@logix-tt.com
Whole thread Raw
In response to Make Trigger run after completion of ENTIRE transaction  ("Henry Ortega" <juandelacruz@gmail.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "CN"
Date:
Subject: Need a SQL to create sets of hobbies
Next
From: Harald Fuchs
Date:
Subject: Re: Need a SQL to create sets of hobbies