PostgreSQL Rewrite Rules

Since version 10, PostgreSQL supports the concept of rewrite rules, which allow you to change how queries are executed. 

In fact, rewrite rules are how views are implemented in PostgreSQL. When you access a view, your query is actually rewritten according to the rule that was created when you created the view. A view is basically a rewrite rule, as we're about to see.