Part 114: Refreshing Materialized Views: Concurrent Refresh
Because materialized views are cached snapshots, they must be refreshed as underlying data updates.
1. Refresh Syntax
-- Standard refresh (Locks the view against reads during refresh):
REFRESH MATERIALIZED VIEW mv_monthly_category_sales;
-- Concurrent refresh (Zero downtime! Allows reads while refreshing):
REFRESH MATERIALIZED VIEW CONCURRENTLY mv_monthly_category_sales;
(Note: CONCURRENTLY requires a unique index on the materialized view).
Key Takeaways
- Always create a unique index on materialized views so you can use
REFRESH ... CONCURRENTLYin production without blocking reads.
In Part 115, we explore User-Defined Functions (UDF): Scalar Functions!

