Re: Rules/Trigges Trade-offs

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: josh(at)agliodbs(dot)com
Cc: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>, pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Rules/Trigges Trade-offs
Date: 2002-12-06 23:30:13
Message-ID: 200212062330.gB6NUDl20018@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql

Josh Berkus wrote:
>
> Bruce, Richard,
>
> > Triggers are mostly for testing/modifying the row being
> > inserted/updated, while rules are better for affecting other rows or
> > other tables.
>
> Hmmm. Thought that there were also some other criteria:
>
> 1) Rules can't use indexes to do their processing, so Rules which query large
> secondary tables can be a bad idea (maybe this has changed?)

I don't think this is true. Rewrite is before optimizer so it should be
optimized just the same.

>
> 2) Only Rules can "DO INSTEAD"; thus, only Rules are good for defining
> Read/Write views.

True.

> 3) There are no AFTER Rules, making, for example, a rule with a table check on
> the new data impractical, so you'd want to use Triggers or Constraints

We have changed ordering in 7.3 where I think INSERT rules are _after_
the insert.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Josh Berkus 2002-12-06 23:54:07 Re: Rules/Trigges Trade-offs
Previous Message Josh Berkus 2002-12-06 23:25:49 Re: Rules/Trigges Trade-offs

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-12-06 23:54:07 Re: Rules/Trigges Trade-offs
Previous Message Josh Berkus 2002-12-06 23:25:49 Re: Rules/Trigges Trade-offs