Re: REFRESH MATERIALIZED VIEW CONCURRENTLY is blocking autovacuum on table

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Dirk Krautschick <dee-kay(at)gmx(dot)de>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: REFRESH MATERIALIZED VIEW CONCURRENTLY is blocking autovacuum on table
Date: 2026-02-09 11:11:37
Message-ID: cf0c607f151186ba0907ec51bd3f5321f5084b9a.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2026-02-09 at 02:17 +0100, Dirk Krautschick wrote:
> I have a situation here where a frequent 
>
>  REFRESH MATERIALIZED VIEW CONCURRENTLY
>
> is preventing autovacuum on some tables kind of running into a circle of growing.

I'm not sure I understand you correctly.

REFRESH MATERIALIZED VIEW CONCURRENTLY will block VACUUM on the materialized
view, because the statements take conflicting locks.

But the statement won't block VACUUM on the underlying tables.
However, if REFRESH MATERIALIZED VIEW CONCURRENTLY is running for a long time,
you will have a long-running transaction, and VACUUM won't be able to clean
up tuples that became dead later.

> Why is this acutally blocking autovacuum and what is the best practice to prevent 
> this excelt just not refreshing the materialized view frequently? :-)

I also have trouble understanding that sentence.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Karlsson 2026-02-09 13:40:42 Re: Support logical replication of DDLs
Previous Message Vitaly Davydov 2026-02-09 10:42:56 Re: Support logical replication of DDLs