Materialized Views
REFRESH MATERIALIZED VIEW ... WITH NO DATA
Lock mode ACCESS EXCLUSIVE
Risk MEDIUM
Blocks reads, writes, other DDL
pgfence rule
refresh-matview-blocking 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.