pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Luc Lachance <jllachan@nsd.ca>
To: josh@agliodbs.com
Cc: Bruce Momjian <pgman@candle.pha.pa.us>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Rules/Trigges Trade-offs
Date: Mon, 09 Dec 2002 11:11:32 -0500
Message-ID: <3DF4C0B4.68BA54B9@nsd.ca> (raw)
References: <200212061634.gB6GYbt02565@candle.pha.pa.us>
	<200212061525.49284.josh@agliodbs.com>

Josh,

Thanks for the info.  

I need to change an insert into an update when the key already exists.
I have been using a rules to test it on a small set (table) and it
works.
"Rules can't use indexes" just scared me. I will have to test on a
larger set.
Also, I had the impression that if a trigger returned NULL, one would
get the equivalent of "DO NOTHING".
Am I wrong with that assumption?

JLL

 

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?)
> 
> 2) Only Rules can "DO INSTEAD"; thus, only Rules are good for defining
> Read/Write views.
> 
> 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
> 
> etc.
> 
> There are, IMHO, some things Rules are better for, and some things Triggers
> are better for.   I tend to use all Triggers except for updatable views,
> simply because using a mix of Rules and Triggers can be very hard to keep
> track of, but YMMV.
> 
> --
> -Josh Berkus
>  Aglio Database Solutions
>  San Francisco



view thread (14+ messages)  latest in thread

Message-ID: <3DF4C0B4.68BA54B9@nsd.ca>
Permalink:  ../3DF4C0B4.68BA54B9@nsd.ca/
Also on:    postgresql.org/message-id/3DF4C0B4.68BA54B9@nsd.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jllachan@nsd.ca, josh@agliodbs.com, pgman@candle.pha.pa.us
  Subject: Re: Rules/Trigges Trade-offs
  In-Reply-To: <3DF4C0B4.68BA54B9@nsd.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox