Re: rules: evaluate inputs in advance

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: rules: evaluate inputs in advance
Date: 2006-05-14 10:10:40
Message-ID: 20060514101040.GA4852@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, May 14, 2006 at 08:01:39AM +0200, Markus Schiltknecht wrote:
> > What you probably want is a function that is given the row and then
> > executes the two statements on a per row basis. This has the effect you
> > want but gives up the major benefit of rules, wholesale query
> > restructuring like views which allows the executor to find better
> > plans. The executor can't see inside a trigger so it can't optimise.
>
> Isn't that an argument for keeping rewrite rules instead of using
> something trigger like for updatable views? Wouldn't it be feasible to
> teach the executor how to handle multiple queries with some
> pre-evaluated input?

Well, I notice that the SQL standard defines something called WITH, so
what you want is something like:

WITH OLD AS ( SELECT blah )
DO
( UPDATE <rule1>
; DELETE <rule2> )

The standard doesn't allow you apply one WITH clause to two statements
but that is what you want. The implementation though would be, well,
difficult...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tino Wildenhain 2006-05-14 12:18:49 Re: problem with compiling with readline library
Previous Message Sebastian Małyska 2006-05-14 10:08:53 problem with compiling with readline library