Re: trigger Before or After
От | Albe Laurenz |
---|---|
Тема | Re: trigger Before or After |
Дата | |
Msg-id | A737B7A37273E048B164557ADEF4A58B17D92E58@ntex2010i.host.magwien.gv.at обсуждение исходный текст |
Ответ на | trigger Before or After (avpro avpro <avprowebeden@gmail.com>) |
Список | pgsql-general |
avpro avpro wrote: > in the pgsql documentation > (http://www.postgresql.org/docs/9.1/static/sql-createtrigger.html) > > > 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 In your example (the trigger updates a second table) it should make no difference if the trigger is BEFORE or AFTER INSERT. The difference is that in a BEFORE trigger you can modify the values that will be inserted before the INSERT actually happens. > 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? I don't quite understand. You will have access to the OLD and NEW values in both BEFORE and AFTER triggers. In an AFTER trigger, the table row has already been modified. > what's the difference related to performance concerning a trigger Before Insert compared with a > trigger After Insert? I don't think that there is a big difference, but you can easily test it: Insert 100000 rows with a BEFORE trigger on the table and compare the time it takes to inserting 100000 rows with an AFTER trigger. Yours, Laurenz Albe
В списке pgsql-general по дате отправления: