Re: Rules going away

From: "Igor Neyman" <ineyman(at)perceptron(dot)com>
To: Ondrej Ivanič <ondrej(dot)ivanic(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Rules going away
Date: 2011-09-29 17:38:43
Message-ID: F4C27E77F7A33E4CA98C19A9DC6722A2082532E5@EXCHANGE.corp.perceptron.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: Ondrej Ivanič [mailto:ondrej(dot)ivanic(at)gmail(dot)com]
> Sent: Wednesday, September 28, 2011 6:47 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: Re: Rules going away
>
> Hi,
>
> > folks, don't use RULES! use triggers -- and as much as possible, keep
> > triggers simple, short, and to the point (simple validation, custom
> > RI, auditing/logging, etc).
>
> I like them :). 'DO INSTEAD' rules are great for partitioning so you
> can insert (or update) to parent table and 'DO INSTEAD' rule takes
> care about the rest.
>
> --
> Ondrej Ivanic
> (ondrej(dot)ivanic(at)gmail(dot)com)

Years ago (PG version 8.2), I was working on implementing partitioned tables, and evaluated whether to use triggers or rules to "automagically" redirect inserts/updates/delete from main table to appropriate partition based on the value of partitioning key.

Unfortunately, I didn't document my research, but the result was that triggers were unusable for my purposes, and I ended up with the rules calling functions where using dynamic sql I decide which partition should be used for insert/update/delete (at least on "selects" PG takes care of choosing proper partition, of course with properly set configuration parameter).

These rules (and functions they call) work perfectly for me all these years in many, many, many installations.
So, until PG takes care of the problem I'm solving with the rules (implementing "complete" partitioning feature, and not just on "selects"), please leave rules where they are, they definitely have their use when properly implemented with specific purpose.

Regards,
Igor Neyman

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Reid Thompson 2011-09-29 17:48:19 Re: Solaris 10u9, PG 8.4.6, 'c' lang function, fails on 1 of 5 servers
Previous Message John R Pierce 2011-09-29 17:37:22 Re: PDT but not WEST