Reputation: 1
I looked up official documents and researched them, but I still don't know what to use in what situations. Could you tell me a simple example and the difference? What are the advantages of having to write a RULE?
Upvotes: 0
Views: 442
Reputation:
Forget about rules.
The Postgres Wiki recommends to never use them
Why not?
Rules are incredibly powerful, but they don't do what they look like they do. They look like they're some conditional logic, but they actually rewrite a query to modify it or add additional queries to it.
That means that all non-trivial rules are incorrect. Depesz has more to say about them.
When should you?
Never. While the rewriter is an implementation detail of VIEWs, there is no reason to pry up this cover plate directly.
(emphasis mine)
Upvotes: 2