Re: what are rules for?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: what are rules for?
Дата
Msg-id 20080624153906.GC16068@svana.org
обсуждение исходный текст
Ответ на Re: what are rules for?  ("Michael Shulman" <shulman@mathcamp.org>)
Ответы Re: what are rules for?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Tue, Jun 24, 2008 at 10:28:00AM -0500, Michael Shulman wrote:
> I have read the manual.  As I pointed out, the only examples of rules
> in the manual are (1) something which may be better done with a
> trigger, and certainly *can* be done with a trigger, whatever the
> speed considerations may be, and (2) something which doesn't seem to
> work very well, and seemingly (from my PoV) *would* be done better
> with triggers if triggers were allowed in that situation.

It possible that if rules wern't the only way currently to implement
(updateable) views, then they might have been ripped out a long time
ago. Thing is, people like views and there is currently no other way to
do them.

> My question was, what else *can* you do with a rule that you *can't*
> do with a trigger?  Are rules only a way to speed up things that could
> also be done with triggers?

Well, views for one. Rules work by manipulating queries, trigger work
by manipulating tuples. Rules have their problems, but sometimes
they're the only way. Updateable views are the major use case.

FWIW, I wonder if the multiple evaluation problem could be solved by
the WITH patch, since the original rule could be stuffed in a WITH
clause and then the rule applied on top of it.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Вложения

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

Предыдущее
От: "Michael Shulman"
Дата:
Сообщение: Re: what are rules for?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: what are rules for?