trigger Before or After

Поиск
Список
Период
Сортировка
От avpro avpro
Тема trigger Before or After
Дата
Msg-id CAAQdDnnb9E89=RxZbu6Fdv1eLtM7bQG9CLAsmYWxKZarnzXRQg@mail.gmail.com
обсуждение исходный текст
Ответы Re: trigger Before or After  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Re: trigger Before or After  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
i haven't seen anything referring to: how is affected the data inserted in the new table by a trigger Before Insert compared with a trigger After Insert? and anything related to performance

for example:

tables: actuals (summarize the total running hours), log (the functional hours are inserted in LOG as time)
 function: sum
view: timeview (where running hours are calculated as a difference)
-- Function: sum()

-- DROP FUNCTION sum();

CREATE OR REPLACE FUNCTION sum()RETURNS trigger AS
$BODY$begin
update actuals
set 
hours = hours + (select time from time_view 
where idlog = (select max(idlog) from timeview))
where actuals.idmac =
(SELECT idmac FROM selectedmac) ; return new; end$BODY$ LANGUAGE plpgsql VOLATILE COST 100; ALTER FUNCTION sum() OWNER TO user;



--trigger
CREATE TRIGGER update_actuals_tg01
  AFTER INSERT
  ON log
  FOR EACH ROW
  EXECUTE PROCEDURE sum();


I read somewhere (I don't find the link anymore) that if the trigger is After Insert, the data available in the table LOG might not be available anymore to run the trigger. is that correct? or I might understood wrong?

what's the difference related to performance concerning a trigger Before Insert compared with a trigger After Insert?

thank you
have a sunny day

В списке pgsql-general по дате отправления:

Предыдущее
От: rahulk
Дата:
Сообщение: Integrating PostgreSQL with Elasticsearch and Kibana
Следующее
От: Albe Laurenz
Дата:
Сообщение: Re: trigger Before or After