Re: Rules going away - Mailing list pgsql-general

From Igor Neyman
Subject Re: Rules going away
Date
Msg-id F4C27E77F7A33E4CA98C19A9DC6722A2082532E5@EXCHANGE.corp.perceptron.com
Whole thread Raw
In response to Re: Rules going away  (Ondrej Ivanič <ondrej.ivanic@gmail.com>)
Responses Re: Rules going away
a dumb question regarding RULES
List pgsql-general
> -----Original Message-----
> From: Ondrej Ivanič [mailto:ondrej.ivanic@gmail.com]
> Sent: Wednesday, September 28, 2011 6:47 PM
> To: pgsql-general@postgresql.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.ivanic@gmail.com)

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

Unfortunately, I didn't document my research, but the result was that triggers were unusable for my purposes, and I
endedup 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
configurationparameter).
 

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
notjust on "selects"), please leave rules where they are, they definitely have their use when properly implemented with
specificpurpose.
 

Regards,
Igor Neyman

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: PDT but not WEST
Next
From: Reid Thompson
Date:
Subject: Re: Solaris 10u9, PG 8.4.6, 'c' lang function, fails on 1 of 5 servers