by munk-a · 6y ago · 0 comments
1. As they're called in postgres at least
2. https://www.postgresql.org/docs/current/sql-creatematerializ...
If you start to need any kind of flexibility over refreshing the table, you'll need to move to using a plain old table anyway.
It's my understanding that there is a proposed feature, with a proof-of-concept floating around, called "Incremental View Maintenance", which is auto-update of dependent Materialized Views when their dependent base-tables change.
https://wiki.postgresql.org/wiki/Incremental_View_Maintenanc...
Materialized view with IVM option created by CRATE INCREMENTAL MATERIALIZED VIEW command. Noted this syntax is just tentative, so it may be changed.
When a materialized view is created, AFTER triggers are internally created on its all base tables.
When the base tables is modified (INSERT, DELETE, UPDATE), this view is updated incrementally in the trigger function.
I think there are some performance/technical things that are getting sorted out with this, but it would be a killer feature.It's the one thing I wish Postgres had that it doesn't. You have to use triggers to do this currently.
In particular, an event-sourced world becomes much easier to implement and maintain with the DB handling all the incremental magic.
[1] https://spaghettidba.com/2011/08/03/enforcing-complex-constr...