Re: RULES - Mailing list pgsql-sql

From Ross J. Reedstrom
Subject Re: RULES
Date
Msg-id 20010522095355.E18984@rice.edu
Whole thread Raw
In response to Re: RULES  (Martín Marqués <martin@bugs.unl.edu.ar>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "Mikheev, Vadim"
Date:
Subject: RE: [HACKERS] Re: possible row locking bug in 7.0.3 & 7.1
Next
From: Najm Hashmi
Date:
Subject: Re: Calculating the age of a person