Re: Deprecating RULES

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Deprecating RULES
Date: 2012-10-17 18:30:41
Message-ID: 507EF951.3020403@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 10/17/2012 10:46 AM, Greg Stark wrote:
>
> I dislike both of the explanations above which don't actually explain
> why people shouldn't use rules (Josh does say they're tricky which is
> a start). Just telling people we hate parts of the system doesn't
> really come off well and leaves them wondering why.
>
> I would suggest something like
>
> Warning: RULES are tricky to use correctly. They rewrite the original
> query into a new query before it is run and it is very hard to
> correctly anticipate and rewrite every possible input query into the
> desired result. There are also unexpected interactions with other
> components when RULES do something unexpected such as rewrite a single
> query to return two result sets.
>
> For most applications it's much simpler and more predictable to use
> TRIGGERs. ROW level triggers are evaluated for each row the original
> query is about to process (or has just finished processing) and this
> makes them much easier to follow. Statement level TRIGGERs can be used
> for audit logs and similar operations which need to run once per
> statement.
>

I am not sure where to stick it but we should also include the fact that
rules are almost always slower that a trigger/function comparative.

Sincerely,

JD

>

--
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Support, Training, Professional Services and Development
High Availability, Oracle Conversion, Postgres-XC
@cmdpromptinc - 509-416-6579

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2012-10-17 18:32:21 Re: Deprecating RULES
Previous Message Tom Lane 2012-10-17 18:19:24 Re: Deprecating RULES