Re: Rule or Function and Trigger?

From: Giorgio Valoti <giorgio_v(at)me(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Rule or Function and Trigger?
Date: 2009-04-04 12:19:50
Message-ID: 42D87D5B-717B-4034-A8CE-E97AE5FBA4B1@me.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Il giorno 03/apr/09, alle ore 16:58, Tom Lane ha scritto:

> "James B. Byrne" <byrnejb(at)harte-lyne(dot)ca> writes:
>> I am beginning to migrate some functionality from an application
>> prototype into the DBMS. One of these elements is time stamping row
>> insertions and updates.
>
>> I have been reading about rules, functions and triggers in regards
>> to this issue. So, of course, now I have myself completely
>> befuddled. From what I can determine from the documentation, it
>> makes little difference to the DBMS whether I set a rule on insert
>> and one on update for each table or define a function and set a
>> trigger for insert or update on each table.
>
>> If this is indeed the case then which way is the preferred method?
>
> A trigger is very much preferred. Rules are not as easy as they look.
> Triggers are a bit more notationally cumbersome, but they tend to
> do what you expect without any surprises.

Are there some situations when using a rule is clearly superior than a
trigger?

I experimented with rules, with good result, but I’d rethink my
approach if triggers are more "reliable".

Thank you in advance

--
Giorgio Valoti

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin 2009-04-04 14:07:06 Re: strange behavior of plpgsql function
Previous Message Scott Marlowe 2009-04-04 11:16:39 Re: high load on server