pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: pgsql-sql@postgresql.org
Subject: Re: RULES
Date: Tue, 22 May 2001 09:53:55 -0500
Message-ID: <20010522095355.E18984@rice.edu> (raw)
In-Reply-To: <01052210440603.28396@bugs>
References: <01052213190000.01962@txino.mikasa.eh>
	<01052210440603.28396@bugs>

On Tue, May 22, 2001 at 10:44:06AM +0300, Mart?n Marqu?s wrote:
> On Mar 22 May 2001 20:19, J.Fernando Moyano wrote:
> > Deleting is broken if it deletes more than one row. The rule is executed
> > only one time each delete command, and not one time each deleted row.
> >
> > It's this OK ??? Am i wrong ???
> > It's a "feature" ??  ;-)
> 
> That's the right behaviour!
> Each time you do a delete, besides the delete, it will execute the update....
> If more then one row is deletes, update.... gets executed only once.
> 

Rules are rewrites of the SQL query, before it gets planned and
optimized, so they are good for things that need to happen once per
statement. Triggers, on the other hand, fire per tuple, when the actual
bits are going into/out of the underlying table. They're good for things
that need to happen per tuple.  

See Bruce's book for the basics:

http://www.ca.postgresql.org/docs/aw_pgsql_book/node166.html

Ross



view thread (22+ messages)  latest in thread

Message-ID: <20010522095355.E18984@rice.edu>
Permalink:  ../20010522095355.E18984@rice.edu/
Also on:    postgresql.org/message-id/20010522095355.E18984@rice.edu

 · 

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: reedstrm@rice.edu
  Subject: Re: RULES
  In-Reply-To: <20010522095355.E18984@rice.edu>

* 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