Materialized Views

REFRESH MATERIALIZED VIEW CONCURRENTLY

Lock mode EXCLUSIVE
Risk LOW
Blocks writes, other DDL
REFRESH MATERIALIZED VIEW CONCURRENTLY daily_revenue;

What this does

Despite the name, EXCLUSIVE is the second-strongest lock mode, one step below ACCESS EXCLUSIVE. It allows ordinary reads to continue (only ACCESS SHARE is compatible with it) but blocks writes and a second concurrent refresh. It has no transaction-block restriction of its own; the "cannot run inside a transaction block" error people hit almost always comes from the CREATE UNIQUE INDEX CONCURRENTLY the view depends on, not from this statement.

Read more

More in Materialized Views