There are a few unfortunate aspects of materialized views that we must consider:
- The contents are completely static
- They cannot be the target of INSERT, UPDATE, or DELETE statements
- Refreshing their contents may be slow
By static, we mean that the rows stored in the materialized view are the result of the SELECT statement we used to define it. It would be a great way to bootstrap a reporting table of some kind, but then, we see the next item in our list: no modifications. A natural consequence of this is that we can't build manual maintenance procedures designed to top off the contents. This means we must refresh the contents of the materialized view all at once with this statement:
REFRESH MATERIALIZED VIEW pgbench_accounts; ...