Re: Rule vs Trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
Cc: "Richard Broersma Jr *EXTERN*" <rabroersma(at)yahoo(dot)com>, rongkai(dot)zhao(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Rule vs Trigger
Date: 2007-06-26 14:04:26
Message-ID: 18188.1182866666@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at> writes:
> Richard Broersma Jr wrote:
>> 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.

Huh? That would be true for a FOR EACH ROW trigger, but a STATEMENT
trigger fires once per 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.

I find this unlikely. The overhead involved in setting up a rule
is probably larger than that involved in calling a trigger.
The real question is whether you need access to the modified data
or not --- a statement-level trigger doesn't currently get that.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-06-26 14:21:42 Re: LC_CTYPE and matching accented chars
Previous Message Gurjeet Singh 2007-06-26 13:44:51 Re: a JOIN on same table, but 'slided over'