Re: rules: evaluate inputs in advance

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: rules: evaluate inputs in advance
Дата
Msg-id 20060514101040.GA4852@svana.org
обсуждение исходный текст
Ответ на Re: rules: evaluate inputs in advance  (Markus Schiltknecht <markus@bluegap.ch>)
Ответы Re: rules: evaluate inputs in advance  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: "Sebastian Małyska"
Дата:
Сообщение: problem with compiling with readline library
Следующее
От: Tino Wildenhain
Дата:
Сообщение: Re: problem with compiling with readline library