
The Postgres Rule Manager (1988) [pdf] - mpweiher
http://db.cs.berkeley.edu/papers/tse88-rulemgr.pdf
======
ddebernardy
There are a few good questions on StackOverflow on Postgres rules. For
instance:

[https://stackoverflow.com/questions/5894142/what-are-
postgre...](https://stackoverflow.com/questions/5894142/what-are-postgresql-
rules-good-for/)

TL;DR: don't use them except in a few edge cases.

~~~
mpweiher
What I found interesting is that the paper claims they use the mechanism
internally for a bunch of relational DB features:

"Lastly, our rule system can provide database services such as views,
protection, integrity constraints, and referential integrity simply by
applying the rules system in particular ways. Consequently, no special purpose
code need be included in POSTGRES to handle these tasks."

Is that still the case or, considering the Rule Manager is not recommended,
has it been replaced for internal services?

I remember Stonebraker's Turing Award Lecture, where he talks about their
attempt at an "ALWAYS" command not working, so I was wondering whether the
Rule Manager talked about here is that thing that didn't work or the thing
they replaced it with.

Looking at the talk again, he says that they figured out ALWAYS wouldn't work
around 86-87[1] and this paper is 88, so I am guessing this is the
replacement.

[1] [https://youtu.be/sEPTZVGk3WY?t=1843](https://youtu.be/sEPTZVGk3WY?t=1843)

~~~
colanderman
Modern PostgreSQL views are internally implemented using rules
([https://www.postgresql.org/docs/current/static/rules-
views.h...](https://www.postgresql.org/docs/current/static/rules-views.html))

~~~
anarazel
True. But it's imo sad thing that it is so (at the very least it leads to
duplicated functionality and duplicates query tree copies, but it also makes
it harder to implement functionality like automatic matview usage etc). I'm
quite sure that nobody would implement views in today's postgres that way. If
there weren't the fact that there's still resistance to removing rules, I'd
argue we should reimplement them.

