From: | Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Statement triggers 7.4 NEW/OLD |
Date: | 2003-04-26 08:50:06 |
Message-ID: | 3EAA483E.2060204@web.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Josh Berkus wrote:
>>IMHO statement triggers instead should have access to the NEW and OLD
>>rows through some mechanism. I can think of NEW and OLD being reference
>>cursors in the case of statement triggers, and the trigger then can
>>FETCH the rows from there.
>>
>>
>
>Yeah; how else could it possibly work?
>
>
>
Why do it easy if you can have it difficult? ;-) If I want to perform
row by row actions I use a row level trigger!
Statement triggers need to work like this:
Instead of
NEW.foo := 1;
you code
UPDATE NEW SET foo=1;
If the statement trigger doesn't offer a complete SETOF RECORD, It's
pretty useless.
In my case, updates and deletes on a table could possibly touch
thousands of rows at the same time, and the trigger will update
aggregated values in another table, and insert or delete a third one
with 3-4 additional statements. This is pretty fast if implemented as
true statement trigger, but will possibly blow the system if done row by
row. Imagine a single statement, that triggers ROW_COUNT*4 statements,
where ROW_COUNT can easily be 1000, 10000 or much more!
Regards,
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | A.Bhuvaneswaran | 2003-04-26 08:53:28 | Re: PL/PgSQL Question |
Previous Message | Ian Barwick | 2003-04-26 06:52:29 | Re: sorting chinese characters |