Search Postgresql Archives

[PERFORM] trigger Before or After

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux