Re: what are rules for? - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: what are rules for?
Date
Msg-id 20080624144408.GA4822@alvh.no-ip.org
Whole thread Raw
In response to what are rules for?  ("Michael Shulman" <shulman@mathcamp.org>)
List pgsql-general
Adam Rich wrote:

> One interesting example is having rules and triggers watching for
> deletes or updates on a table.  If many rows are modified, rules
> can be faster.  Take this statement:
>
> DELETE FROM mydata WHERE idval BETWEEN 10000 and 20000;
>
> Say this statement deletes 10,000 rows.  The delete trigger would
> get called 10,000 times whereas the rule is essentially executed
> once, since it can share the WHERE clause of the user's query.

This is a use case we should be able to better implement using FOR EACH
STATEMENT triggers, it seems.  We just need to be able to pass the list
of affected tuples to the trigger function, which until now has remained
unimplemented.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-general by date:

Previous
From: "Brandon Metcalf"
Date:
Subject: Re: backslashes in 8.3.3
Next
From: David Siebert
Date:
Subject: Probably been asked a hundred times before.