Materialized Views

REFRESH MATERIALIZED VIEW ... WITH NO DATA

Lock mode ACCESS EXCLUSIVE
Risk MEDIUM
Blocks reads, writes, other DDL
REFRESH MATERIALIZED VIEW daily_revenue WITH NO DATA;

What this does

ACCESS EXCLUSIVE is still taken, but WITH NO DATA only truncates the view without repopulating it, so the lock is brief. The view is left unscannable (marked not-populated) until a real refresh runs.

Read more

More in Materialized Views