Alex Rivera | Logout

PostgreSQL - Are BEFORE triggers more efficient then AFTER triggers?

Asked 2011-03-28T11:35:27.340
9

I just read in the PostgreSQL Documentation - Overview of Trigger behavior, that BEFORE triggers are "more effecient" than AFTER triggers:

If you have no specific reason to make a trigger before or after, the before case is more efficient, since the information about the operation doesn't have to be saved until end of statement.

I do not understand if this is true or what it means for me. Can someone enlighten me? Is this just a homeopatic performance improvement?

Edit
Report

1 Answer

1

The only way you are going to prove it one way or another is to test it and see if it matters for what you are doing.

Thinking logically at the high level... if you are taking an extra step to retain more information vs not taking the extra step of course one is more work than the other. Just as walking one extra step is more work even though it may not take you a noticeable time difference. For example to walk 10 feet with 10 steps vs 11 steps.

answered 2011-03-28T13:15:31.380

Your Answer