Re: Deprecating RULES - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Deprecating RULES
Date
Msg-id 507C1317.9020200@dunslane.net
Whole thread Raw
In response to Re: Deprecating RULES  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Deprecating RULES  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
On 10/15/2012 09:07 AM, Simon Riggs wrote:
> On 15 October 2012 11:41, Greg Stark <stark@mit.edu> wrote:
>> On Mon, Oct 15, 2012 at 8:00 AM, Simon Riggs <simon@2ndquadrant.com> wrote:
>>> Please can anyone show me the SQL for a rule that cannot be written as
>>> a view or a trigger? I do not believe such a thing exists and I will
>>> provide free beer to the first person that can prove me wrong.
>> Being written as a view doesn't help you because views use rules. I
>> repeat, the very fact that we need rules to implement views prove
>> rules are necessary for some purposes.
> No, it just means there is some aspect of similar underlying infrastructure.
>
> Denial of free beer looks like proof to me...
>


*sigh*

First, as Tom said, the onus of proof is on you. You can't transfer it 
away with this offer of free beer.

Second, he's actually told you one advantage rules can have over 
triggers, but you've pretty much chosen to ignore it:

> Triggers necessarily operate on a row-at-a-time basis.  In theory,
> for at least some bulk operations, a rule could greatly outperform
> a trigger.  It's difficult to walk away from that - unless somebody
> can prove that the advantage doesn't ever accrue in practice.

I have seen rules used instead of triggers for precisely this reason. 
Yes, the fact that COPY bypasses rules is something you need to 
remember, but that makes it a limitation of the feature, not an absolute 
reason not to use it. (I rarely if ever use them myself - can't recall 
the last time I did, but there is plenty of legacy use out there.)

cheers

andrew




pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Deprecating RULES
Next
From: Amit kapila
Date:
Subject: Re: patch submission: truncate trailing nulls from heap rows to reduce the size of the null bitmap [Review]