On 10/15/2012 09:07 AM, Simon Riggs wrote:
On 15 October 2012 11:41, Greg Stark <st...@mit.edu> wrote:
On Mon, Oct 15, 2012 at 8:00 AM, Simon Riggs <si...@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



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to