Search Postgresql Archives

Re: Rule vs Trigger

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

 



Richard Broersma Jr wrote:
> --- Alfred Zhao <rongkai.zhao@xxxxxxxxx> wrote:
>> Suppose I want to update a statistics table S after an
>> insertion into an activity table A. In order to update S
>> automatically, I can either create a rule on A or create
>> an after trigger on A. What's the performance implication
>> on using rule vs trigger? Thanks in advance.
>
> My understanding is that Triggers offer better performance
> than rules do.

A trigger FOR EACH STATEMENT will execute the trigger function
for each row affacted by the statement. A rule would only
execute one additional statement. So if you can do it with a rule
conveniently, the rule will probably be faster.

Yours,
Laurenz Albe


[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