concurrentRefreshMatviewLock

Diagnostic Category: lint/safety/concurrentRefreshMatviewLock

Since: vnext

Sources: - Inspired from: pgfence/refresh-matview-concurrent

Description

REFRESH MATERIALIZED VIEW CONCURRENTLY still acquires an EXCLUSIVE lock.

While concurrent refresh allows reads during the refresh, it still blocks DDL and other write operations on the materialized view. On large views, this can take a long time.

Examples

Invalid

refresh materialized view concurrently my_view;
code-block.sql:1:1 lint/safety/concurrentRefreshMatviewLock ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ! REFRESH MATERIALIZED VIEW CONCURRENTLY still acquires an EXCLUSIVE lock.

  > 1 │ refresh materialized view concurrently my_view;
      │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 

  i Concurrent refresh allows reads but still blocks DDL and writes. Consider the impact on long-running refreshes.


Valid

select 1;

How to configure


{
  "linter": {
    "rules": {
      "safety": {
        "concurrentRefreshMatviewLock": "error"
      }
    }
  }
}